-1

我试过这个:

<li ng-repeat="todo in todos" class="{{todo.isCompleted ? 'test'}}">
<input type="checkbox" class="toggle"/>
<label>{{todo.text}}</label><button class="destroy"></button>
</li>

但后来我得到一个错误:

Error: Lexer Error: Unexpected next character at columns 17-17 [?] in expression [todo.isCompleted ? 'test']

4

2 回答 2

6

像这样使用ng-class

<li ng-repeat="todo in todos" ng-class="{ 'test' : todo.isCompleted }">

参考

于 2013-07-08T11:00:28.493 回答
2

ng-class="{ 'test' : todo.isCompleted }"

于 2013-07-08T10:40:19.100 回答