Angular11 MSAL B2C登录实例 (二)

前言

上文介绍了在app.module.ts里的配置,本文着重讲解下在app-routing.module.ts和index.html里的设置。

步骤

在文件中主要需要添加以下代码

app-routing.module.ts

复制代码
const initialNavigation = (!BrowserUtils.isInIframe() && !BrowserUtils.isInPopup()) || window.location.href.indexOf("logout") > 0;

.@NgModule({
  imports: [RouterModule.forRoot(routes, {
    useHash: true,
    // Don't perform initial navigation in iframes or popups, except for logout
    initialNavigation: initialNavigation ? 'enabled' : 'disabled' // Remove this line to use Angular Universal
  })],
  exports: [RouterModule]
})

index.html

复制代码
<body>
...
  <app-redirect></app-redirect>
</body>

后言

下一篇文章会讲解在在组件中的使用

相关推荐
Latchh2 分钟前
PDF打开不要密码却显示已加密,前端怎么判断
前端·图像处理·人工智能·计算机视觉·pdf
秋天的一阵风3 分钟前
🧐 为什么大厂 RAG 从不用纯向量检索?
前端·面试·ai编程
恋猫de小郭13 分钟前
Flutter + EmbeddingGemma 2,谷歌发布完全端侧的 AI Edge Foresight
android·前端·flutter
Nebula_g18 分钟前
JavaSE加强:Commons-io框架
java·开发语言·算法·javase
FITA阿泽要努力19 分钟前
第1周·第2讲|一道综合代码推演
服务器·前端·python·agent.
iCxhust20 分钟前
如何批量导出edge保存的密码
前端·windows·edge
Do_It_Today21 分钟前
php url路由入门实例
开发语言·php
JarvanMo22 分钟前
写 Flutter 不用再套六层 Widget 了
前端
小羊没烦恼!30 分钟前
关于大型asp.net应用系统的架构-架构的选择
java·服务器·开发语言·前端·c#
GISer_Jing36 分钟前
height、line-height、font-size相同字体遮挡问题
前端·ai