SAP Spartacus的自定义Angular Url Matcher实现

简介: SAP Spartacus的自定义Angular Url Matcher实现

https://microlearning.opensap.com/media/Custom+Angular+URL+Matchers+in+Spartacus+Storefront±+SAP+Commerce+Cloud/1_hhjqkiuy/178316081

Angular, and Spartacus by extension, allows you to configure string patterns to match routes against URLs. An example is /product/:productCode, which has two segments. The first segment, product, is a static segment that determines the URL is a product page type, and the second segment, :productCode, is a dynamic parameter.


上面提到的url,有两个segments,其中第一个product segment,为静态segment,说明该url代表一个product page type,而第二个segment :productCode, 是一个动态参数。


有时存在需求,需要在一个segment内同时实现静态和动态两种segment:


However, there may be cases where you need to work with URL segments that contain both static and dynamic parts within a single segment. An example is /macbook-p, where mackbook is a dynamic product code, and -p is a static part that determines the URL is a product page type. In this case, you need to implement a custom Angular UrlMatcher.


这种需求通过UrlMatcher来满足。


源代码:

image.png


将自定义实现的matcher配置到module里:

image.png


image.png

上面代码中paths里传入的:customProductCode是一个新的属性,需要通过normalizer添加进去:

image.png


最后将custom normalizer注入到app module中:


image.png

相关文章
|
7月前
SAP Fiori Launchpad url 参数 sap-app-origin-hint 的含义
SAP Fiori Launchpad url 参数 sap-app-origin-hint 的含义
30 0
|
7月前
|
缓存 前端开发 JavaScript
基于 Spartacus 的 Angular Storefront 性能优化建议
基于 Spartacus 的 Angular Storefront 性能优化建议
28 0
|
7月前
SAP Fiori 应用 url 中的 DraftUUID 参数的含义
SAP Fiori 应用 url 中的 DraftUUID 参数的含义
26 0
|
5月前
钉钉接收事件订阅的url可以加自定义参数吗?
钉钉接收事件订阅的url可以加自定义参数吗?
38 0
|
7月前
|
Web App开发 资源调度 开发者
SAP Fiori Elements 应用 OData 元数据请求 url 里的模型名称决定逻辑
SAP Fiori Elements 应用 OData 元数据请求 url 里的模型名称决定逻辑
50 0
|
7月前
|
存储 JavaScript 前端开发
SAP UI5 OData 请求 url 中的参数 sap-value-list=none
SAP UI5 OData 请求 url 中的参数 sap-value-list=none
34 0
|
7月前
|
缓存
SAP Fiori Elements 应用加载时的 url 参数 sap-ui-xx-viewCache=false
SAP Fiori Elements 应用加载时的 url 参数 sap-ui-xx-viewCache=false
26 0
|
7月前
|
前端开发
给 SAP Fiori Launchpad 配置自定义 url
给 SAP Fiori Launchpad 配置自定义 url
86 0
|
7月前
|
存储 API 数据库
SAP BTP 平台 ABAP 编程环境如何维护自定义 Unit Of Measure 数据库表 T006
SAP BTP 平台 ABAP 编程环境如何维护自定义 Unit Of Measure 数据库表 T006
60 0
|
7月前
|
安全 网络安全
SAP CRM WebClient UI 支持的一些 url 参数
SAP CRM WebClient UI 支持的一些 url 参数
74 0