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>

后言

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

相关推荐
Beginner x_u3 分钟前
CSS 中的高度、滚动与溢出:从 height 到 overflow 的完整理解
前端·css·overflow·min-height
vx1_Biye_Design8 分钟前
基于web的物流管理系统的设计与实现-计算机毕业设计源码44333
java·前端·spring boot·spring·eclipse·tomcat·maven
MediaTea10 分钟前
Python:MRO 解密 —— C3 线性化算法
java·开发语言
sunfove12 分钟前
Python小游戏:在 2048 游戏中实现基于线性插值(Lerp)的平滑动画
开发语言·python·游戏
摘星编程15 分钟前
React Native + OpenHarmony:Animated 弹簧动画实现代码
javascript·react native·react.js
tqs_1234515 分钟前
倒排索引数据结构
java·前端·算法
2501_9445264217 分钟前
Flutter for OpenHarmony 万能游戏库App实战 - 抽牌游戏实现
android·开发语言·python·flutter·游戏
a程序小傲19 分钟前
听说前端又死了?
开发语言·前端·mysql·算法·postgresql·深度优先
Yan.love40 分钟前
【CSS-布局】终极方案:Flexbox 与 Grid 的“降维打击”
前端·css
Ashley_Amanda40 分钟前
Python 进阶:从熟练到精通的核心技能体系
开发语言·python