【发布时间】:2013-02-19 11:30:59
【问题描述】:
angularjs 代码:
app.directive('test', function(){
return {
restrict: 'A',
scope: {
myId: '@'
},
link: function(scope) {
alert(scope.myId);
}
}
});
你可以看到指令中有一个scope: { myId: '@' }。
还有html代码:
<div test my-id='123'></div>
你可以看到我定义了一个my-id='123'。
我希望该指令会提醒123,但它会提醒undefined。我的错在哪里?
PS:这是一个现场演示:http://plnkr.co/edit/sL69NqWC70Qfwav5feP2?p=preview
【问题讨论】:
标签: angularjs angularjs-directive angularjs-scope