更改Angular函数末尾的组件



在完成login((函数(重定向到microsoft登录(后,如何更改为受限页面组件?

public-page.component.ts

login() {
this.msalService.loginRedirect();
//switch to restricted-page here.
}

app-routing.module.ts:

const routes: Routes = [{
path: 'public-page', component: PublicPageComponent
}, {
path: 'restricted-page', component: RestrictedPageComponent, canActivate: [MaslGuard]
}, {
path: '', redirectTo:'public-page', pathMatch:'full',
}];

在登录功能中,您必须添加:

if (login successfull){
this.router.navigate(['/restricted-page'])
}

最新更新