动态路由角度5

时间:2018-07-16 01:04:57

标签: angular typescript angular5

我正在尝试创建一个包含动态标签的边栏。我正在使用角度打字稿。

目标:

enter image description here

我还尝试了什么: 我试图添加到构造函数中:

router: Routes

逻辑

在网站的主要组件上,用户将按下页面中央的单个按钮,调用一个函数,该函数根据用户按下的次数动态地在左侧生成这些选项卡按钮。

项目结构:

enter image description here

注释:

about.component.htmlabout.component.ts是用户单击URL时重定向到的主页(当前:localhost:4200)。因此,触发动态标签的按钮位于about.component.html中。边栏由sidebar-routes.config.ts(放置标签的位置)控制,示例代码或此文件为:

{ path: 'api', title: 'Dynamic 1',  icon: '', class: '', image: false }

layout.routes.ts将路径定向到组件。一个例子是:

{path: 'api', component: AboutComponent},

如何完成:

这就是我被困住的地方。本质上,我需要从sidebar-routes.config.ts中调用的函数中注入layout.routes.tsabout.component.ts。我不确定如何将这两个文件导入about.component.ts,以便我可以访问其中两个文件的resetConfig()push()方法。也许有人对动态更新这些文件有更好的建议?

0 个答案:

没有答案