Azure active directory azure/msal angular在angular 6中成功登录后未重定向到主组件

Azure active directory azure/msal angular在angular 6中成功登录后未重定向到主组件,azure-active-directory,angular6,msal,Azure Active Directory,Angular6,Msal,我正在使用msal angular(1.0.0)和msal(^1.3.0)。成功登录后,页面为空,不会重定向到主页。但当我刷新页面时,它会显示主页内容 我接着说: 在我的应用程序中,当登录成功时,用户应重定向到主页 { path: 'home', component: HomeComponent, canActivate : [MsalGuard] }, { path: 'profile', component: ProfileComponent, }, { path: '', redirect

我正在使用msal angular(1.0.0)和msal(^1.3.0)。成功登录后,页面为空,不会重定向到主页。但当我刷新页面时,它会显示主页内容

我接着说:

在我的应用程序中,当登录成功时,用户应重定向到主页

{ path: 'home', component: HomeComponent, canActivate : [MsalGuard] },
{ path: 'profile', component: ProfileComponent, },
{ path: '',
redirectTo: 'home',
pathMatch: 'full'
} 
我也尝试过@azure/msal angular-0.1.4
如何在不刷新的情况下重定向到主页?

下面是一个使用azure ad/msal的示例

我直接链接到路由页面,正如sruthi所说,但是登录成功应该会将您带到您在单击“登录”之前尝试到达的位置。根据sruthis路由,如果您位于站点根目录,它应该将您重定向到主目录


在您上面的代码中,路由是不正确的,为什么您保护的是家庭而不是个人资料?此外,根据代码中的路由设置,在加载页面的第二天,您将跳转到登录页面。以及homecomponent

嗨,在这种情况下,这将不起作用。 试试这个:

    msal:loginSuccess, () => {
this.router.navigate(['/home'])
}

下面的代码可能会帮助您设置路由:routes=[{path:'profile',component:ProfileComponent,canActivate:[MsalGuard]},{path:'',component:HomeComponent}];谢谢你的回复,斯鲁西。这不起作用:-(这段代码根本不起作用,实际上le HomeComponent被实例化了两次…不好.)。。