爲什麼$ scope.watch不能與'model'配合使用? http://jsfiddle.net/lesouthern/8PUtP/5/雙向數據綁定手錶
.directive('testDirective',function() {
return {
restrict : 'A',
scope : {
model : '=ngModel'
},
link : function($scope,$element,$attrs) {
$scope.$watch('model',function(x) {
console.log('this is model: ' + x);
});
}
}
});
在這種情況下 「=」 應爲 「@」[小提琴](http://jsfiddle.net/jcsYE/) – rGil
[這個答案](HTTP:/ /stackoverflow.com/a/14063373/2013981)總結。 – rGil