daoudaDiallo / ng2-acl

Role based permissions for Angular v2++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ERROR TypeError: Cannot read property 'roles' of undefined

myke11j opened this issue · comments

This is exactly like showed in docs, but it is keep giving the error in browser console.

<div class="mdl-layout__header-row">

        <!-- Add spacer, to align navigation to the right -->
        <div class="mdl-layout-spacer"></div>

        <!-- Navigation with router directives-->
        <nav class="mdl-navigation">
          <a class="mdl-navigation__link" [routerLink]="['/user-profile']">User Profile</a>
          <a class="mdl-navigation__link" [routerLink]="['/advance-user-profile']">Advance User Profile</a>
          <a *ngIf="can('admin')" class="mdl-navigation__link" [routerLink]="['/contact-user']">Contact User</a>
        </nav>
      </div>

This is the error

ERROR TypeError: Cannot read property 'roles' of undefined
    at AppComponent.AclService.can (index.js:181)

However, I have setup the permission for user and even logging this.aclService.getRoles() shows the correct user role. And after that is throws the above error.

Any help would be much appreciated.

Hi @myke11j , please reinstall ng2-acl and try again. Normally problem is fixed.
Thanks for your feedback