search

Home  >  Q&A  >  body text

javascript - Why is it printed twice?

<button ng-disabled="test()">按钮</button>
angular.module('myApp', []).

controller('c',function($scope){
    $scope.test=function(){
        console.log('为什么打印两次');
        return false;
    }
})

高洛峰高洛峰2764 days ago1132

reply all(1)I'll reply

  • 天蓬老师

    天蓬老师2017-05-27 17:46:43

    I reproduced your code, see: JSFiddle-Problem Reproduction

    Angular’s ​​dirty value check, for the specific reason, see: Understanding the Angular data binding process
    I won’t go into details! ! !

    reply
    0
  • Cancelreply