canActivate 之外的路由器:[AuthGuard] 不起作用
router outside canActivate: [AuthGuard] doesn't work
我的路由有问题。
我尝试使用此代码:
const routes: Routes = [
{
path: 'home', component: HomeComponent, canActivate: [AuthGuard], children: [
{ path: 'events', component: EventsComponent },
{ path: 'package', component: PackageComponent },
{ path: 'settings', component: SettingsComponent }
]
},
{ path: 'login', component: LoginComponent },
{ path: '**', redirectTo: 'home' },
{ path: "register", component: RegisterComponent },
{ path: "usersforgetpassword", component: ResetPassComponent }
];
无法导航,忘记密码 (ResetPassComponent) 和新帐户 (RegisterComponent)。
Html代码:
<StackLayout>
<Label [nsRouterLink]="['/usersforgetpassword']" class="text-center footnote">
<FormattedString>
<Span text="Forgot password? "></Span>
</FormattedString>
</Label>
</StackLayout>
<StackLayout>
<Label [nsRouterLink]="['/register']" class="text-center footnote">
<FormattedString>
<Span text="New Account "></Span>
</FormattedString>
</Label>
</StackLayout>
请问,我的路由器有什么问题吗?看不懂。
谢谢
请放置这些
{ path: "register", component: RegisterComponent },
{ path: "usersforgetpassword", component: ResetPassComponent }
之前
{ path: '**', redirectTo: 'home' }
通配符路由应始终在末尾,否则低于该路由的路由将无法工作,因为它匹配所有可能的字符串。
我的路由有问题。
我尝试使用此代码:
const routes: Routes = [
{
path: 'home', component: HomeComponent, canActivate: [AuthGuard], children: [
{ path: 'events', component: EventsComponent },
{ path: 'package', component: PackageComponent },
{ path: 'settings', component: SettingsComponent }
]
},
{ path: 'login', component: LoginComponent },
{ path: '**', redirectTo: 'home' },
{ path: "register", component: RegisterComponent },
{ path: "usersforgetpassword", component: ResetPassComponent }
];
无法导航,忘记密码 (ResetPassComponent) 和新帐户 (RegisterComponent)。
Html代码:
<StackLayout>
<Label [nsRouterLink]="['/usersforgetpassword']" class="text-center footnote">
<FormattedString>
<Span text="Forgot password? "></Span>
</FormattedString>
</Label>
</StackLayout>
<StackLayout>
<Label [nsRouterLink]="['/register']" class="text-center footnote">
<FormattedString>
<Span text="New Account "></Span>
</FormattedString>
</Label>
</StackLayout>
请问,我的路由器有什么问题吗?看不懂。
谢谢
请放置这些
{ path: "register", component: RegisterComponent },
{ path: "usersforgetpassword", component: ResetPassComponent }
之前
{ path: '**', redirectTo: 'home' }
通配符路由应始终在末尾,否则低于该路由的路由将无法工作,因为它匹配所有可能的字符串。