Share, Support, Subscribe!!
Subscribe: https://bit.ly/3kk36Nh
Youtube: / worldtechtube
In this video we will learn how to create an authentication guard in angular application.
Basically we will try to learn the use of Angular Route guard.
We will create a simple authentication guard by implementing the CanActivate interface. We will then add the in app.routing.module.ts
const routes: Routes = [
{path: '', component: HomeComponent},
{path: 'home', component: HomeComponent},
{path: 'login', component: LoginComponent},
{path: 'register', component: RegisterComponent},
{path: 'addNewCar', component: NewCarComponent, canActivate:[AuthenticationGuard]},
{path: 'logout', component: LogoutComponent}
];
The guard will return true/false and if the value is true then it will continue navigation otherwise not.