1
我正在与Angular 2挣扎。我已经定义了所有的路由,但是当我输入例如“mysiteurl:4200/password-recovery”或“mysiteurl:4200/email-confirm/sometoken”它驱使我随机到家/配置组件(不需要)或密码恢复或电子邮件确认组件(所需)。我不明白,重定向到家庭/配置文件。有任何想法吗?角2:随机路由
该应用程序的路由模块代码:
const appRoutes: Routes = [
{ path: 'login', component: LoginComponent },
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: 'password-recovery', component: PasswordRecoveryComponent },
{ path: 'email-confirm/:token', component: EmailConfirmComponent },
{ path: 'home', component: HomeComponent,
children: [
{ path: '', redirectTo: 'profile', pathMatch: 'full' },
{ path: 'profile', component: ProfileComponent },
{ path: 'companies', component: CompaniesComponent },
{ path: 'roles', component: RolesComponent },
{ path: 'documents/:type', component: DocumentsComponent },
{ path: 'users', component: UsersComponent },
{ path: 'documents-identity', component: DocumentsIdentityComponent },
{ path: 'forms', component: FormsComponent },
{ path: 'password-recovery-detail', component: PasswordRecoveryDetailComponent },
{ path: 'card', component: CardComponent },
]
}
];
@NgModule({
imports: [
RouterModule.forRoot(appRoutes, { useHash: true })
],
exports: [
RouterModule
]
})
export class AppRoutingModule { }
你配置'useHash'为您导航。所以导航使用哈希方法:'mysiteurl:4200 /#/ password-recovery' – mrkosima
它不会影响结果..有时密码恢复,有时在家/配置文件 –