javascript - What is the difference between these two mechanisms in angular? ?
三叔
三叔 2017-06-12 09:32:19
0
1
660

Scenario 1: controller('c',function($scope){

    $scope.test=function(){
        console.log(111);//打印一次
    }
    $scope.test();
})

Case 2:<button ng-disabled="test()"></button>

controller('c',function($scope){

    $scope.test=function(){
        console.log(111);//打印两次
    }
})

Why is situation 2 printed twice?

三叔
三叔

reply all(1)
女神的闺蜜爱上我

ng-disabled To pass an expression, it will be disabled when the expression is true by default. Then if you put a method, it will definitely be executed.
Is the page code in your situation 1 missing? How do you trigger this method to be executed once?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template