我不明白为什么或为什么不angularjs隔离范围使用或不$ $手表?
例如:
app.directive('fooDirective', function() {
return {
scope: {
readonly: '=' or '@' or '&'
},
link: function (scope, element, attrs) {
// should I use $watch here or not ?
scope.$watch('readonly', function() {
// do I require to do so???
});
}
};
});
这取决于你想要做什么。 – zeroflagL 2015-02-23 14:29:17
重要吗?我想知道它是否为该属性颁发或不是?我的意思是,如果在范围隔离之后,我会有两块手表或一块? – IamStalker 2015-02-23 14:31:35
通过使用'='激活数据绑定,而'@'是只读的,最好是字符串 – DonJuwe 2015-02-23 14:35:11