使用双卷bracer的指令的输入不起作用
Input to a directive using double curly bracers not working
我已经编写了这个指令,它使用d3.js渲染一些星星。当我给它硬编码输入时,它工作得很好,但当我从我的作用域给它输入时,就不工作了。这是我指令的一部分(表现出相同的行为):
app.directive('stars', function() {
return {
scope: {
width: "@",
height: "@",
maxStars: "@",
filled: "@"
},
link: function(scope, element, attrs) {
console.log(attrs);
console.log(attrs.filled);
}
}
});
我这样称呼我的指令:
<table ng-app="app" ng-controller="Mainctrl">
<tbody>
<tr ng-repeat="agent in data">
<td stars width="200" height="100" max-stars="5" filled="{{agent.ratings.avg}}"></td>
</tr>
</tbody>
</table>
打印属性给我(以及其他值):
filled: "4"
height: "100"
maxStars: "5"
stars: ""
width: "200"
而打印attrs.filled则显示"未定义"。
我发现我可以清楚地看到对象attrs有一个键"filled"的值,但当我试图访问它时,我会得到"undefined"。
这已经在原始帖子的评论中得到了回答。
相关文章:
- 新的自定义角度指令不起作用
- AngularJS,自定义指令不起作用@ plnkr
- AngularJS + Coffeescript - 'Hello World' 指令不起作用
- 使用 $provide 重命名第三方角度指令 - 不起作用
- 带有指令不起作用的 AngularJS 动态表单字段 ID
- AngularJS:双向数据绑定 - 带有ng重复的指令 - 不起作用
- 为什么我在 AngularJs 中的指令不起作用
- 剑道指令不起作用
- ng-单击指令不起作用
- 为什么这个 angularjs 指令不起作用
- 角度引导添加新指令不起作用
- AngularJS + Facebook喜欢指令不起作用
- 带有 ngModel 绑定的 AngularJS 自定义指令不起作用
- Angularjs 指令不起作用“意外令牌”
- jQuery插件中的Angular指令不起作用
- 可重复使用的按钮指令不起作用
- Angular JS自定义指令不起作用
- 带有编译函数和ng-show的角度对话框指令不起作用
- 一个元素上的多个指令不起作用
- AngularJS:drag-n-drop指令不起作用