我一直在尝试创建一个基于 cli 的示例 angular4 应用程序,其中包含一个主模块和 3 个产品模块(产品本身是一个路由参数,可以懒惰地加载每个产品屏幕)。
这是我的示例 - https://github.com/shankarvn/angular4lazyloading
重现步骤
光盘应用程序
npm 安装
ng服务-p 4003
在浏览器中 localhost:4003 => 应该加载 3 张卡片,显示 product1、product2 和 product3。此时,单击product1,您将看到路线更改和product1 的ui 加载。现在单击仪表板,您将在控制台中看到一个错误
ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'product1/dashboard'
Error: Cannot match any routes. URL Segment: 'product1/dashboard'
at ApplyRedirects.noMatchError (router.es5.js:1404) [angular]
at CatchSubscriber.selector (router.es5.js:1379) [angular]
at CatchSubscriber.error (catch.js:104) [angular]
不确定我做错了什么 - 只是在 product1 模块延迟加载时加载了仪表板路由。加载 product1 模块时不应该注册路由。任何帮助表示赞赏。
谢谢。