angularjs – 为什么ng-mouseover不适用于ng-if
我正在尝试在具有“ng-if”的图像上使用“ng-mouSEOver”指令并且它不起作用但是如果我使用“ng-show”指令它可以工作,大家能告诉我为什么吗?或者这是一个AngularJS问题?
在AngularJS文档中,我无法阅读有关它的任何内容:https://docs.angularjs.org/api/ng/directive/ngMouseover NG-秀 <button ng-show="true" ng-mouSEOver="countOne = countOne + 1" ng-init="countOne=0"> Increment (when mouse is over) </button> Count: {{countOne}} NG-如果 <button ng-if="true" ng-mouSEOver="countTwo = countTwo + 1" ng-init="countTwo=0"> Increment (when mouse is over) </button> Count: {{countTwo}} 小提琴:http://plnkr.co/edit/Wb6bjyJdHj5qoH7fxGFJ?p=info 解决方法
您观察到的行为是由ngIf如何工作引起的 –
from the docs
这基本上意味着如果你使用ng-if,你需要使用$parent.像这样: <button ng-if="true" ng-mouSEOver="$parent.countTwo = countTwo + 1" ng-init="$parent.countTwo=0"> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |