0

这是我的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}}] 开始的表达式 [{{menu.permission}}] 的第 2 列中的标记“{”无效键。 http://errors.angularjs.org/1.6.4/ $parse/syntax?p0=%7B&p1=invalid%20key&p2=2&p3=%7B%7Bmenu.permission%7D%7D&p4=%7Bmenu.permission%7D%7D 在angular.js:66 at AST.throwError (angular.js:15090) at AST.object (angular.js:15079) at AST.primary (angular.js:14968) at AST.unary (angular.js:14956) at AST.multiplicative (angular.js:14943) at AST.additive (angular.js:14934) at AST.relational (angular.js:14925) at AST.equality (angular.js:14916) at AST.logicalAND (angular. js:14908)

4

1 回答 1

0

请尝试不使用括号 {{}} 传递

<li ng-class="{active: collapseVar == menu.Id}" ng-repeat="menu in side_menu"
                  permission-only="menu.permission" permission>

case 仅允许接受only: '=?permissionOnly'来自文档的参数 ( )。 https://github.com/Narzerus/angular-permission/blob/master/src/permission/directives/permission.js

于 2017-09-11T08:05:38.623 回答