【发布时间】:2013-11-08 03:32:08
【问题描述】:
我正在尝试对具有隔离作用域的 ng-repeat 项目使用指令,但它不起作用。我正在遍历每个项目并使用 inboxuser-select 指令将其着色为红色。但是,当我打开指令时,它不会显示我的任何范围值。这里有什么问题?谢谢
html文件
<li class="inbox-chatter" data-ng-
repeat="inboxuser in inboxusers">
<p inboxuser-select selected={{inboxuser}}">{{inboxuser}}</p>
</li>
directive.js
.directive('inboxuserSelect', function() {
return {
restrict: 'A',
scope: {
selected: "@"
},
link: function(scope, element, attrs) {
scope.selected.css('color','red');
}
}
});
【问题讨论】:
-
什么是
inboxuser。如果是JS对象怎么用css方法 -
我为了显示的目的简化了函数。假设收件箱用户是一个字符串
标签: javascript angularjs angularjs-directive angularjs-scope angularjs-ng-repeat