这是我的HTML代码
<li ng-class="{active: collapseVar == menu.Id}" ng-repeat="menu in side_menu"
permission-only="{{menu.permission}}" permission>
<a style="color:#FFFFFF; background-color:#00BCD4" ng-click="check(menu.Id)">
<i class="fa {{menu.icon}} fa-2x" style="margin-right:5px;"></i>{{menu.name}}
<span class="fa arrow"></span>
</a>
<ul class="nav nav-second-level" collapse="collapseVar!=menu.Id">
<li ui-sref-active="active" ng-repeat="sub_menu in menu.sub_views">
<a style="color:#FFFFFF; background-color:#59C8D7" ui-sref="{{sub_menu.state}}">
{{sub_menu.name}}
</a>
</li>
</ul>
</li>
我需要动态填充权限 但是我收到了这个错误
angular.js:14525错误:[$ parse:syntax]语法错误:令牌'{' 表达式[{{menu.permission}}]第2列的无效键 从[{menu.permission}}]开始。 http://errors.angularjs.org/1.6.4/ $解析/语法P0 =%7B&安培; P1 =无效%20key&安培; P2 = 2及P3 =%7B%7Bmenu.permission%7D%7D&安培; P4 =%7Bmenu.permission%7D%7D 在AST.object的AST.throwError(angular.js:15090)的angular.js:66处 (angular.js:15079)在AST.primary(angular.js:14968)在AST.unary (angular.js:14956)at AST.multiplicative(angular.js:14943)at AST.additive(angular.js:14934)at AST.relational(angular.js:14925) 在AST.logicalAND的AST.equality(angular.js:14916) (angular.js:14908)
答案 0 :(得分:0)
请尝试不使用括号{{}}
传递<li ng-class="{active: collapseVar == menu.Id}" ng-repeat="menu in side_menu"
permission-only="menu.permission" permission>
案例权限 - 仅接受来自文档的参数(only: '=?permissionOnly'
)。
https://github.com/Narzerus/angular-permission/blob/master/src/permission/directives/permission.js