Fall 1: Controller('c',function($scope){
$scope.test=function(){
console.log(111);//打印一次
}
$scope.test();
})
Fall 2:<button ng-disabled="test()"></button>
controller('c',function($scope){
$scope.test=function(){
console.log(111);//打印兩次
}
})
Warum wird Situation 2 zweimal gedruckt?
ng-disabled 要傳一個(gè)表達(dá)式,當(dāng)表達(dá)式默認(rèn)為true時(shí)會(huì)禁用,那你放了一個(gè)方法它肯定會(huì)去執(zhí)行。
你情況一的頁(yè)面代碼是不是漏貼了,怎么觸發(fā)這個(gè)方法執(zhí)行一次的?