X Y
{{x}}
link:function(scope,elem,attr){ scope.show=true; scope.show1=false; scope.choiceme=function (i){ console.log(scope.show,scope.show1); scope.show1=!scope.show1; scope.show =!scope.show; console.log(scope.show,scope.show1); }; elem.find("p").on("click",function(){{ scope.show=!scope.show; console.log(scope.show,scope.show1); scope.$apply(); }); }
现在的问题出现的很诡异就是ng-click事件会自动触发apply可是choiceme()中scope.show的状态的确是变化了可是没有同步到Dom中这个问题请教了
Look at your code, is it triggered when you click
p
标签的时候,应该scope.choiceme
和elem.find("p").on("click"
?Is this reasonable?