[英]Angular 10, problem header navigation for different type user
I have a header on the web page that according to the type of user (normal or admin) shows a navigation header with 2 different operations, an admin sees all registered users and their reservations while a normal user sees their reservations and can to book.我在 web 页面上有一个 header,根据用户类型(普通或管理员)显示具有 2 种不同操作的导航 header,管理员可以看到所有注册用户及其预订,而普通用户可以看到他们的预订并可以预订。 I used a '* ngIf' to show the different header but on login with normal user it shows me the header of the admin and more 'always in the header I have the logout button which shows a welcome message with the name of the 'user who accesses but if I don't update the page is not seen.我使用“* ngIf”来显示不同的 header,但是在使用普通用户登录时,它向我显示了管理员的 header 以及更多“总是在 header 中”我有注销按钮,它显示了一条带有“用户”名称的欢迎消息谁访问但如果我不更新页面是看不到的。 how can i solve?我该如何解决? thank you.谢谢你。
app-component: https://i.stack.imgur.com/v9tA5.png应用组件: https://i.stack.imgur.com/v9tA5.png
header: https://i.stack.imgur.com/yOerJ.png header: https://i.stack.imgur.com/yOerJ.png
it would be more efficient if you post the ts component file to see how permissions are arriving.如果您发布 ts 组件文件以查看权限如何到达,效率会更高。 A suggestion is to unificate the code block, and check the permission only in the item of the menu.一个建议是统一代码块,只检查菜单项的权限。 To avoid duplicate code.以避免重复代码。
<div *ngIf="loggedUser">
<ul>
<li *ngIf="isAdmin">
<a>LINK1</a>
</li>
<li *ngIf="!isAdmin">
<a>LINK2</a>
</li>
</ul>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.