Issue
I am new to Angular and jhipster stack, we are building an angular - spring-boot project with jhipster stack. For rendering the menu items in the Nav Bar we are using '*jhiHasAnyAuthority' in the navbar.component.html like below:
<li *jhiHasAnyAuthority="'ROLE_ADMIN' ngbDropdown routerLinkActive="active">
Is there any way we can read the value for jhiHasAnyAuthority dynamically?
Solution
Not sure what you mean by "dynamically" but you can inject AccountService
into the constructor of your component and use its functions and in particular hasAnyAuthority()
. This is what the directive uses. Look at its definition in src/main/webapp/app/core/auth/account.service.ts
of your project.
There are many examples on how it is used in your generated project.
Answered By - Gaël Marziou
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.