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>

后言

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

相关推荐
雕刻刀几秒前
服务器模拟断网
linux·服务器·前端
zs宝来了1 分钟前
Vite 构建原理:ESBuild 与模块热更新
前端·javascript·框架
2301_814809864 分钟前
实战分享Flutter Web 开发:解决跨域(CORS)问题的终极指南
前端·flutter
ayqy贾杰1 小时前
GPT-5.5+Codex全自动搓出macOS游戏,创作链路首次真正连续
前端·面试·游戏开发
wengqidaifeng1 小时前
C++从菜鸟到强手:1.基础入门
开发语言·c++
hhb_6181 小时前
PHP 8.x 核心特性与工程化开发实践指南
开发语言·php
geovindu2 小时前
go: Flyweight Pattern
开发语言·设计模式·golang·享元模式
xyq20243 小时前
TypeScript中的String类型详解
开发语言
英俊潇洒美少年3 小时前
Vue2/Vue3 vue-i18n完整改造流程(异步懒加载+后端接口请求)
前端·javascript·vue.js
小糖学代码9 小时前
LLM系列:1.python入门:15.JSON 数据处理与操作
开发语言·python·json·aigc