我无法完成这项工作,知道我错过了什么吗?
<li ng-repeat="person in persons" ng-class="selected:currentPersonID===person.id">
显示 currentPersonID
和 person.id
显示了适当的数据,但我得到了该表达式的 Angular 解析错误。
最佳答案
你应该写
<li ng-repeat="person in persons" ng-class="{'selected': currentPersonID === person.id}">
ngClass
docs说:
<ANY ng-class="{expression}">
...
</ANY>
那里需要大括号。
单引号记录在同一页的评论中(我知道,应该在官方文档中,但是......)
关于AngularJS ng 类表达式抛出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20075307/