Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
App Routing Module for Azure AD B2C protected Angular App
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { HomeComponent } from './home/home.component';
import { FetchDataComponent } from './fetch-data/fetch-data.component';
import { CounterComponent } from './counter/counter.component';
import { MsalGuard } from '@azure/msal-angular';
const routes: Routes = [
{
path: '',
component: HomeComponent,
pathMatch: 'full'
},
{
path: 'counter',
component: CounterComponent,
canActivate: [
MsalGuard
]
},
{
path: 'fetch-data',
component: FetchDataComponent,
canActivate: [
MsalGuard
]
},
];
@NgModule({
imports: [RouterModule.forRoot(routes, { useHash: false })],
exports: [RouterModule]
})
export class AppRoutingModule { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment