2013-07-30 45 views
1

我可以通过ng-repeat动态添加HTML属性吗?ng-repeat的动态HTML属性AngularJS

<select> 
    <option ng-repeat="thing in things" {{thing.ghosted||'disabled'}}> 
     {{thing.name}} 
    </option> 
</select> 

我在这里做错了什么?

回答

3

对于这样的事情,使用指令会很好。

<select> 
    <option ng-repeat="thing in things" ng-disabled="thing.ghosted"> 
     {{thing.name}} 
    </option> 
</select> 
+0

+1我甚至不知道指令被内置的。 –

+1

+1我知道,但不明白'{{thing.ghosted ||“禁用”}}'意义 –