当前位置:网站首页>SAP Spartacus 默认路由配置的工作原理
SAP Spartacus 默认路由配置的工作原理
2022-06-26 21:18:00 【华为云】
这个默认配置文件的名称:default-routing-config.ts
查看哪些地方消费了 defaultRoutingConfig:
provudeDefaultConfig 是一个 helper 函数:
这个 RoutingModule.forRoot 方法又会在什么时候被调用呢?
在这两处:base-storefront.module.ts 和 storefront-foundation.module.ts:
注意 forRoot 方法返回参数的类型:ModuleWithProviders:
因为 import 这些 module 的消费 module,imports 区域的类型就是 any[] | Type<any> | ModuleWithProviders<{}>)[]
关于 ValueProvider 各参数的说明:
provide:注入令牌。通常是 Type 或 InjectionToken 的实例,但也可以是 any 实例。
multi:如果为 true,则注入器返回实例数组。这对于允许多个提供者散布在多个文件中以向公共令牌提供配置信息很有用。
一个例子:
const locale = new InjectionToken<string[]>('locale');const injector = Injector.create({ providers: [ {provide: locale, multi: true, useValue: 'en'}, {provide: locale, multi: true, useValue: 'sk'}, ]});const locales: string[] = injector.get(locale);expect(locales).toEqual(['en', 'sk']);
ModuleWithProviders:对 NgModule 及其相关 providers 的包装。
边栏推荐
- VB.net类库,获取屏幕内鼠标下的颜色(进阶——3)
- 0 basic C language (3)
- 慕课11、微服务的用户认证与授权
- Record a redis large key troubleshooting
- What are the accounting elements
- leetcode刷题:字符串04(颠倒字符串中的单词)
- leetcode刷题:字符串05(剑指 Offer 58 - II. 左旋转字符串)
- StringUtils判断字符串是否为空
- 关于appium踩坑 :Encountered internal error running command: Error: Cannot verify the signature of (已解决)
- 宝藏又小众的覆盖物PBR多通道贴图素材网站分享
猜你喜欢
Simple Lianliankan games based on QT
leetcode刷题:字符串06(实现 strStr())
Godson China Science and technology innovation board is listed: the market value is 35.7 billion yuan, becoming the first share of domestic CPU
【连载】说透运维监控系统01-监控系统概述
Record a redis large key troubleshooting
GEE:计算image区域内像素最大最小值
Yonghui released the data of Lantern Festival: the sales of Tangyuan increased significantly, and several people's livelihood products increased by more than 150%
与 MySQL 建立连接
Treasure and niche cover PBR multi-channel mapping material website sharing
茂莱光学科创板上市:拟募资4亿 范一与范浩兄弟为实控人
随机推荐
基于启发式搜索的一字棋
Godson China Science and technology innovation board is listed: the market value is 35.7 billion yuan, becoming the first share of domestic CPU
C: 反转链表
GEE:计算image区域内像素最大最小值
Gee: calculate the maximum and minimum values of pixels in the image area
Fixed length memory pool
在哪家证券公司开户最方便最安全可靠
VB.net类库,获取屏幕内鼠标下的颜色(进阶——3)
基于QT开发的线性代数初学者的矩阵计算器设计
Stop being a giant baby
windows系统下怎么安装mysql8.0数据库?(图文教程)
Hands on deep learning pytorch version 3 - Data Preprocessing
Sword finger offer II 098 Number of paths / Sword finger offer II 099 Sum of minimum paths
y48.第三章 Kubernetes从入门到精通 -- Pod的状态和探针(二一)
【贝叶斯分类2】朴素贝叶斯分类器
0 basic C language (0)
Leetcode(122)——买卖股票的最佳时机 II
How to analyze financial expenses
Detailed explanation of stored procedures in MySQL
lotus configurations