Foo*_*ife 9 angularjs ng-class
我使用以下代码"ng-class":
<i class="fa" ng-class="fa-sort-up:tableService.sortState.sortBy==id && tableService.sortState.sortMode=='asc',
fa-sort-down:tableService.sortState.sortBy==id && tableService.sortState.sortMode=='desc',
fa-sort:tableService.sortState.sortBy!=id"></i>
Run Code Online (Sandbox Code Playgroud)
如何修复此错误:
Error: [$parse:syntax] Syntax Error: Token ':' is an unexpected token at column 11 of the expression [fa-sort-up:tableService.sortState.sortBy==id && tableService.sortState.sortMode=='asc',
fa-sort-down:tableService.sortState.sortBy==id && tableService.sortState.sortMode=='desc',
fa-sort:tableService.sortState.sortBy!=id] starting at [:tableService.sortState.sortBy==id && tableService.sortState.sortMode=='asc',
fa-sort-down:tableService.sortState.sortBy==id && tableService.sortState.sortMode=='desc',
fa-sort:tableService.sortState.sortBy!=id]
Run Code Online (Sandbox Code Playgroud)
az7*_*7ar 26
ng-class的工作原理如下:
<i class="fa" ng-class='{"fa-sortup" : x && y, "fa-b": a && b}'></i>
Run Code Online (Sandbox Code Playgroud)
所以,你错过了花括号.
ps如果类名"fa-sortup"包含特殊字符(如' - '),则必须将类名放在字符串中.
| 归档时间: |
|
| 查看次数: |
30533 次 |
| 最近记录: |