【发布时间】:2013-05-11 09:37:24
【问题描述】:
我正在尝试获取指令内的值何时从外部更改,并且它似乎不适用于 scope.$watch 或 attrs.$observe。
我有一个小提琴here。
angular.module('zippyModule', [])
.directive('elem', function(){
return {
restrict: 'E',
transclude:true,
template:"Directive: <span ng-repeat='i in values'>{{i}} </span>",
scope: { values:'=zippyTitle' },
link: function(scope, element, attrs) {
attrs.$observe ('zippyTitle',function(newValue){
console.log (scope.values);
});
scope.$watch ('values',function(newValue){
console.log (scope.values);
});
}
}
});
【问题讨论】:
标签: angularjs angularjs-directive