AngularJS纳克级的前pression抛出错误
问题描述:
我不能做这项工作,任何想法,我缺少的是什么?
I can't make this work, any idea what I'm missing?
<li ng-repeat="person in persons" ng-class="selected:currentPersonID===person.id">
显示 currentPersonID
和 person.id
显示相应的数据,但我得到一个角度解析错误与前pression。
Displaying currentPersonID
and person.id
shows the appropriate data, but I get an Angular parse error with that expression.
答
您应该写
<li ng-repeat="person in persons" ng-class="{'selected': currentPersonID === person.id}">
的 ngClass
文档说:
<ANY ng-class="{expression}">
...
</ANY>
大括号是必要有。
The curly braces are necessary there.
单引号内是在同一个页面上(我知道,应该是对官方的文档,但是......)
The single quotes are documented in a comment on the same page (I know, should be on the official docs, but...)