March 2017
Intermediate to advanced
118 pages
2h 1m
English
The
canActivate
guard is the default mechanism of adding permissions to the application. To see how we can use it, let's take the example from preceding code and remove lazy loading:
const ROUTES = [
{
path: ':folder',
children: [
{
path: '',
component: ConversationsCmp
},
{
path: ':id',
component: ConversationCmp,
children: [...]
}
]
},
{
path: 'contacts',
canActivate: [CanActivateContacts],
children: [
{ path: '', component: ContactsCmp },
{ path: ':id', component: ContactCmp }
]
}
];Where
CanActivateContacts
is defined as shown in the following code:
@Injectable() class CanActivateContacts implements CanActivate { ...Read now
Unlock full access