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>

后言

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

相关推荐
用户3169353811837 分钟前
SpringBoot + Vue 项目生产环境部署完整指南
前端·后端
精英的英11 分钟前
记一次 Qt5 Language Server 开发
开发语言·vscode·qt
Csvn20 分钟前
🔍 TypeScript `satisfies` 操作符:既要类型安全,又要推断的原始字面量类型
前端
烧酒同学21 分钟前
【C++】记录size of std::vector的巧妙坑
开发语言·c++·图形渲染
Csvn27 分钟前
🚦 手写 Promise 并发控制:如何优雅限制异步请求的并发数?
前端
周周哈哈哈34 分钟前
线程创建、执行、退出、回收
java·开发语言
gb421528739 分钟前
python中Web应用服务器
开发语言·前端·python
默_笙1 小时前
💌 为了把"主题色"传给孙子组件,我翻了五层楼——直到遇见了 useContext
前端·javascript
颜进强1 小时前
04 - 一张图看懂 OpenSpec 变更的一生:从创建到归档
前端·后端·ai编程
the_answer1 小时前
JS 垃圾回收机制
前端