ได้โปรดใครช่วยอธิบายฉันหน่อยได้ไหมว่าเหตุใดตัวแปรขอบเขตของ 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>
นี่คือเสียงระเบิด: https://plnkr.co/edit/2CM4vVRshWuJvaBj2q8T?p=preview ก>
ขอบคุณ.
one way !== isolated scopes
- person lin   schedule 11.03.2017