根据用户的角色在菜单中显示不同的内容

时间:2017-05-05 07:55:03

标签: javascript angularjs ionic-framework

我有一个菜单或部分只对某些用户可见。我的数据库中有角色user,role admin1和role admin2。

例如,如何才能让用户和admin2看到第2类?

        {
          "name": "Jack",
          "fname": "Daniel",
          "roles": [
            "ROLE_USER",
          ]
        }

        {
          "name": "Rico",
          "fname": "Phil",
          "roles": [
            "ROLE_ADMIN1",
          ]
        }

        {
          "name": "Admini",
          "fname": "Strator",
          "roles": [
            "ROLE_USER",
            "ROLE_ADMIN2"
          ]
        }

我的代码:

<ion-item class="item-stable animsvdj" ng-click="toggleGroup(group)" ng-class="{active: isGroupShown(group)}">
      <i class="icon" ng-class="isGroupShown(group) ? 'ion-android-contacts' : 'ion-android-contacts'"></i>
      &nbsp; Category
    </ion-item>
    <ion-item class="item-accordion menu-border" ng-show="isGroupShown(group)" ui-sref="menu.disponibilites" menu-close=""><i class="ion-ios-calendar-outline menu-icon"></i>   Category 1</ion-item>

    <!-- Part that should be visible only by admin -->
    <ion-item class="item-accordion menu-border" ng-show="isGroupShown(group)" ui-sref="menu.organiseVisite" menu-close=""><i class="ion-ios-time-outline menu-icon"></i>   Category 2</ion-item>
    <!-- Part that should be visible only by admin -->

    <ion-item class="item-accordion menu-border" ng-show="isGroupShown(group)" ui-sref="menu.trouverUnJeune" menu-close=""><i class="ion-ios-eye-outline menu-icon"></i>   Category 3</ion-item>
谢谢你:)

0 个答案:

没有答案