I have the following route configuration:
export const AppRoutes: Routes = [
{
path: 'secure', component: SecureInformationComponent, data: { permission: 'view_secure_information'}
}
]
Is it possible that every element which is using the routerLink directive is going to be disabled/enabled whether the user has the permission 'view_secure_information'? Such as:
<a [routerLink]="['secure']">Go to secure area of the application</a>
The only possible solution which came to my mind is to implement a CanActivate guard which does the check based on data within the route. But I also have to add on every [routerLink] attached anchor or button which navigates to this secure route another directive which does the same check and disables/enables the element such as:
<a [routerLink]=['secure']" *hasPermission="view_secure_information">Go to secure area of the application</a>
Although this works I would have redundant code and the checks are quite decentralized.