如果我发现自己在“/discover”并刷新页面,它将保持在那里,但是我希望应用程序重新开始(/splash)。
const appRoutes: Routes = [
{ path: '', redirectTo: '/splash', pathMatch: 'full' },
{ path: 'splash' , component: SplashComponent },
{ path: 'discover' , component: DiscoverComponent },
{ path: 'broadcast' , component: BroadcastComponent },
{ path: 'notifications' , component: NotificationsComponent },
{ path: 'notifications/:key' , component: NotificationComponent }
];
export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes);
我已尝试放置一个
router.navigate
在我的父AppComponent中调用
OnInit
&
OnDestroy
然而,它似乎被忽略了。
ngOnInit( ) : void {
this.router.navigate(['splash']);
}
我还尝试在
自然灾害
路由器本身的方法。