请问能有人解释一下,为什么
这里有一个plunker链接: https://plnkr.co/edit/2CM4vVRshWuJvaBj2q8T?p=preview。谢谢。
attrDir
的作用域变量是可见的,而oneWay
的不可见呢?我原本认为scope: {}
也是被隔离的。angular.module('test', []);
angular.module('test').directive('attrDir', attrDir);
function attrDir(){
return {
scope: true,
link: function(scope){
scope.hello = 'attrDir';
}
};
}
angular.module('test').directive('oneWay', oneWay);
function oneWay(){
return {
scope: {
data: '<?'
},
link: function(scope){
scope.hello = 'oneWay';
}
};
}
hello
只会在 attr-dir
中呈现。
<attr-dir>
<span>{{hello}}</span>
</attr-dir>
<one-way>
<span>{{hello}}</span>
</one-way>
这里有一个plunker链接: https://plnkr.co/edit/2CM4vVRshWuJvaBj2q8T?p=preview。谢谢。
one way !== isolated scopes
. - lin