<p class="tab">
<p ng-transclude class="click" ></p>
<i class="iconfont" ng-show="show">X</i>
<i class="iconfont" ng-show="show1">Y</i>
<p ng-hide="show">
<p ng-repeat="x in data" ng-click="choiceme(x)">
{{x}}
</p>
</p>
</p>
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中這個問題請教了
看你的程式碼,點擊
p
标签的时候,应该scope.choiceme
和elem.find("p").on("click"
都觸發了吧?這合理麼?