angularjs controller的成员变量和$scope的成员变量的区别
比如我有代码如下:<scripttype="text/javascript">angular.module("MyModule",[]).controller("MyCo...
比如我有代码如下:
<script type="text/javascript">
angular.module("MyModule",[])
.controller("MyController",['$interval','$scope',
function($interval,$scope){
this.num = 0;
$scope.num = 0;
$interval(function(){this.num = this.num+1;$scope.num = $scope.num+1;},1000);
}]);
</script>
$interval 里的函数只刷新$scope.num的值而不刷新this.num的值,这是何解 谢谢 展开
<script type="text/javascript">
angular.module("MyModule",[])
.controller("MyController",['$interval','$scope',
function($interval,$scope){
this.num = 0;
$scope.num = 0;
$interval(function(){this.num = this.num+1;$scope.num = $scope.num+1;},1000);
}]);
</script>
$interval 里的函数只刷新$scope.num的值而不刷新this.num的值,这是何解 谢谢 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询