Javascript app.comnonent.ts中的路线更改事件
我无法识别路由。我想在路线改变后改变面板条的位置。面板栏位于应用程序中。组件用户可以使用它更改页面。我该怎么办?Javascript app.comnonent.ts中的路线更改事件,javascript,angular,Javascript,Angular,我无法识别路由。我想在路线改变后改变面板条的位置。面板栏位于应用程序中。组件用户可以使用它更改页面。我该怎么办? 我在构造函数中尝试了类似的方法,但问题是构造函数在app.component中一次只执行一次 this.curRouter = window.location.href; if(this.curRouter.includes('test')) { this.routerResult='test'; } else if(this.curRouter.includes('
我在构造函数中尝试了类似的方法,但问题是构造函数在app.component中一次只执行一次
this.curRouter = window.location.href;
if(this.curRouter.includes('test')) {
this.routerResult='test';
} else if(this.curRouter.includes('shipping')) {
this.routerResult='shipping';
} else if(this.curRouter.includes('new')) {
this.routerResult='new';
}
我在构造器中做了类似的东西,它可以工作
router.events.subscribe((event) => {
if (event instanceof NavigationEnd) {
this.subsRouteResult = (event.url).substring(1);
this.changeRoute();
}
})
我在changeRoute方法中有操作。您尝试过任何操作吗?是的,但我失败了。向我们展示您尝试过的操作。
this.curRouter=window.location.href;if(this.curRouter.includes('test')){this.curRouter.includes('shipping')){this.curRouter.includes('shipping')){this.curRouter.includes('new'))else if(this.curRouter.includes('new'){
我在构造函数中尝试了类似的方法,但问题是构造函数在app.component中一次只执行一次。需要提供更多信息吗