2013-07-30 48 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 ||「禁用」}}'意義 –