码迷,mamicode.com
首页 > 其他好文 > 详细

angular的$scope的使用

时间:2017-09-22 20:08:20      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:function   efi   tar   sharp   val   使用   []   mda   变量   

1. 可以在scope中直接使用

// 监听日期变化
			$scope.$watch(‘vaFilter.startEffectiveDate‘, function(newDate, oldDate, scope){
				if (!angular.isUndefined(newDate)) {
					$scope.fromDate = newDate;
				}
			});

  

2. 可以直接监视angular以外的js变量

angular.module(‘myModule‘, []).controller(‘MyCtrl‘, function() {
    $scope.$watch(‘test‘, function(newVal, oldVal){
           //TODO
});
});    

var test = "test"; test 为angular之外的js全局变量

  

angular的$scope的使用

标签:function   efi   tar   sharp   val   使用   []   mda   变量   

原文地址:http://www.cnblogs.com/nelson-hu/p/7576859.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!