- SAP Spartacus UI ConfigurableRou
- SAP 电商云 Spartacus UI 的 Product C
- SAP UI5 sap.ui.vk 命名空间内的控件介绍
- 如何在 SAP 电商云 Spartacus UI 里新建一个页面
- 网站上的 breadcrumb 使用场景浅析
- HTML 按钮(button)的 disable 属性和 dis
- 为什么 SAP 电商云 Spartacus UI SSR 模式下
- SAP 电商云 Spartacus UI 产品搜索结果的设计明细
- SAP 电商云 Spartacus UI Proxy Facad
- Angular @Injectable 注解的工作原理浅析
在该 service 的 init 方法里,有如下的代码调用:
protected configure(): void {
// Router could not be injected in constructor due to cyclic dependency with APP_INITIALIZER:
const router = this.injector.get(Router);
router.resetConfig(this.configureRoutes(router.config));
}
原因是因为 Angular route 数据类型里的 path 和 matcher 字段不能同时使用:


最后计算出的 route 信息里,path 都被赋上了对应的值,只有这些值才能被 Angular router 框架解析到。

有的路由信息比如 product,没有使用 path,而采用的 matchers,如下图所示:

注意字段名为 matchers,而 Angular router 框架 route 数据结构里的字段名为 matcher,因此我们需要 ConfigurableRoutesService,将 matchers 内的值转换成 router 框架接受的 matcher 字段。
转换后的结果如下图所示:

更多Jerry的原创文章,尽在:"汪子熙":

网友评论