angular - How to determine route prior to route guard Angular?
问题描述
so I have lets say 2 routes '/admin-route' and '/superuser-route' and both require 'admin' and 'superuser' privileges respectively to access these routes.
When user clicks on this route I check privileges and if they're false for that user I activate a '/no-access' route guard.
The challenge is that I have breadcrumbs in my app and if the user gets a no-access state I want to display in the breadcrumbs which route he previously accessed.
So if user tries to access '/admin-route' and he doesn't have admin rights the no-access route guard kicks in and I want to have displayed in the breadcrumbs 'Admin' and the same if user tries to access '/superuser-route' and gets no-access page I want 'Superuser' breadcrumb.
I'm having a challenging time figuring out how to tell the route guard which was the previous route to be able to display the correct breadcrumb.
I hope this isn't too confusing and any help is appreciated!
解决方案
在路由守卫或中央服务中有逻辑。
每条有效路线都会更新该属性的值。
当用户移动到无效路线时,使用该属性的值。
像导航结束的实例,--根据您的逻辑使用检查更新属性
推荐阅读
- java - 在Java中分隔十进制值
- typescript - 无需按键即可查看 VS Code 中 Typescript Prop 的所有 Intellisense 选项
- json - 访问 Json 数据
- c# - 没有注册 Func 的 C# DI Func 工厂?
- cassandra - cassandra cql中的限制有什么影响
- merge - Power Query 压缩多个合并操作
- c++ - 使用 move 从派生类分配基础数据会产生错误
- hadoop - Hadoop 3.2.1 ErasureCoding ISA-L 问题?
- regex - 部分网址的正则表达式
- javascript - Windows 正常,所以 RO 会运行