$scope 变化 fun undefine def logs ctr 直接 star
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的使用
来源: http://www.bubuko.com/infodetail-2320293.html