我有一个标签组件服务,其中包含一个设置标签的方法。每个选项卡都有一个指向单独组件的路径。
setTabs(components: any[]) {
// components: [{ title: 'Foo bar', path: 'foo-component', component: FooComponent },
// { title: 'Whoo bar', path: 'whoo-component', component: WhooComponent }]
for (let i = 0; i < components.length; i++) {
let component = components[i];
this.addTab(component);
this._router.config.push({path: component.path, component: component.component});
}
// << DOESNT RESET ROUTE, WHY?? >>
this._router.resetConfig(this._router.config);
}
如何动态添加路线?