ng-click my divs bilan ishlamaydi

Ng-takrorlangan oddiy tartibli ro'yxatim bor va foydalanuvchining ro'yxat elementlaridan biriga kelsa, har bir narsa sodir bo'lishini xohlayman. Biroq, ng-click html ichidagi div'lar bilan ishlamasa, faqat tugma bilan ishlaydi. Avvaliga bu muammo ng-takrorlash bilan tugadi deb o'ylardim, lekin ng-repeat ng-click tashqarisida ham ishlamayapti. Ng-mousedown-dan foydalanishni sinab ko'rdim va bu ham ishlamayapti.

Mana mening html:

<div class="noteItem" ng-mouseleave="btnShow = false" ng-mouseenter="btnShow = true" ng-click="alert('click');">
    
  • {{note.subject|removeHTML}}DELETE
  •  
    </div>
    

    Men bu divdan tashqarida yana bir divni o'ynashga harakat qildim, ammo u hali ishlamadi. Men bu muammoni bir soatcha ushlab turdim.

    0
    Agar ogohlantirishni ko'rsatish uchun alert ("klik") ni kutmoqchi bo'lsangiz, unda siz noto'g'ri bo'lishi mumkin. Agar shunday qilsangiz, ogohlantirishni ishga tushirish uchun $ scope.alert funktsiyasini aniqlasangiz
    qo'shib qo'ydi muallif Ladmerc, manba
    deleteNote funktsiyasini aniqlagandagi tekshiruvchini ko'rsating. Bundan tashqari siz bo'sh hrefni aniqlab olishga harakat qilishingiz mumkin. Quyidagiga qarating: docs.angularjs.org/api/ng/directive/ngHref
    qo'shib qo'ydi muallif Rumpelstinsk, manba
    Vau shu qadar ahmoqona his qilaman, buning uchun rahmat. Uzoq kecha bo'ldi ...
    qo'shib qo'ydi muallif Leo Li, manba

    6 javoblar

    Ng tugmasi bosilganda bajariladigan funksiya va ifodalarni topadi. ogohlantirishlar va konsollarning hech qanday ma'lumoti yo'q, shuning uchun u bunga o'xshamaydi. Nimani qilsangiz, tortib olsa funktsiyasini yaratadi va shu funktsiya ichidagi ogohlantirishni chaqiradi.

    0
    qo'shib qo'ydi

    Ng tugmasi bosilganda bajariladigan funksiya va ifodalarni topadi. ogohlantirishlar va konsollarning hech qanday ma'lumoti yo'q, shuning uchun u bunga o'xshamaydi. Nimani qilsangiz, tortib olsa funktsiyasini yaratadi va shu funktsiya ichidagi ogohlantirishni chaqiradi.

    0
    qo'shib qo'ydi

    As you have a ng-click on the parent element (<div>) as well, the click will be triggered on both. You can cancel parent ng-click on the child with $event.stopPropagation().

    <div ng-mouseleave="btnShow = false" ng-mouseenter="btnShow = true" ng-click="alert('click');">
        
  • {{note.subject|removeHTML}} DELETE
  •  
    </div>
    

    As a side note, ng-click="alert('click') will seek for $scope.alert(), if you are hoping to open the JavaScript basic alert... ;-)

    0
    qo'shib qo'ydi

    As you have a ng-click on the parent element (<div>) as well, the click will be triggered on both. You can cancel parent ng-click on the child with $event.stopPropagation().

    <div ng-mouseleave="btnShow = false" ng-mouseenter="btnShow = true" ng-click="alert('click');">
        
  • {{note.subject|removeHTML}} DELETE
  •  
    </div>
    

    As a side note, ng-click="alert('click') will seek for $scope.alert(), if you are hoping to open the JavaScript basic alert... ;-)

    0
    qo'shib qo'ydi

    You have ng-click in div and also in element, the one being executed is in the element not the ng-click in div.

    Bu kabi div qo'shib, chertish uchun harakat qilib ko'ring.

    <div ng-click="yourScopeMethodHere()">click me</div>
    

    BT-ni, to'g'ridan-to'g'ri JS ogohlantirishini (ng-click) ng-click bilan ishlamaydi.

    0
    qo'shib qo'ydi
    Yo'q, bu noto'g'ri. ikkala ustida ham sinov bo'ladi.
    qo'shib qo'ydi muallif Mistalis, manba

    You have ng-click in div and also in element, the one being executed is in the element not the ng-click in div.

    Bu kabi div qo'shib, chertish uchun harakat qilib ko'ring.

    <div ng-click="yourScopeMethodHere()">click me</div>
    

    BT-ni, to'g'ridan-to'g'ri JS ogohlantirishini (ng-click) ng-click bilan ishlamaydi.

    0
    qo'shib qo'ydi
    Yo'q, bu noto'g'ri. ikkala ustida ham sinov bo'ladi.
    qo'shib qo'ydi muallif Mistalis, manba
    Angular Uzbekistan
    Angular Uzbekistan
    107 ishtirokchilar

    Guruh Angular bo'yicha muloqot qilish uchun ochilgan Sizni qiziqtirsa: @nodejs_uz @react_uz @angular_uz @yiiframework_uz @js_uzb @typescript_uzb @vuejs_uz @ngTashkent @laravel_uz @uzdevgroup Ish o'rinlari @UzDev_jobs

    Javascript UZB
    Javascript UZB
    99 ishtirokchilar

    @js_uzb @vuejs_uz @react_uz @nodejs_uz @angular_uz @ngTashkent @yiiframework_uz @laravel_uz @linux_uzbek @python_uz @swift_uzb —————— @uzdevgroup @UzGeeksGroup ——— @UzDev_Jobs @jobs_uzb

    ngTashkent
    ngTashkent
    77 ishtirokchilar

    Правила просты: 1. Не хамить 2. Не хейтить 3. Реакт не нужен Ссылки: https://t.me/angular_ru - старший брат https://t.me/angular_uz - ангулар на узбекском @js_uzb @vuejs_uz @react_uz @nodejs_uz @yiiframework_uz @uzdevgroup @UzDev_Jobs @tasdev_talks