Hi am developing a angular app having three components all of them have a curd operations i want to add an admin page in app to restrict some users to do some of these operations using toggle button or on/off button.Img is attached I want some thing same like image.ThanksImg link
Juan Pablo Isaza
To restrict access to a page, you can add a guard to the certain route. To do this you should add canActivate option and provide an array of guards that should be called when you go to the route.
To create a guard you can use angular cli and run ng generate guard [name]
There should be canActivate method inside the guard.
For example,
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
if (this.authService.isAuthorized()) {
return true;
}
this.router.navigateByUrl('/dashboard');
return false;
}