angular.js - AngularJS Controller中$scope作用域问题
世界只因有你
世界只因有你 2017-05-15 16:58:04
0
2
454
controllers.controller('ctrl', ['$scope', function($scope) {
  console.log($scope);//
  $scope.add = function() {
    console.log($scope);//
  };
}]);

为什么上面两个作用域的输出是不相等的?

世界只因有你
世界只因有你

reply all(2)
曾经蜡笔没有小新

Both outputs point to the $scope bound to the controller. The first one is executed when the controller is loaded, and the second one is executed when the add method is called. The execution time and status of the two are different.

伊谢尔伦

It is the same object in itself, and the execution content may be different at different times

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!