I want to show / hide routerLink based on some Data from the router. The directive is implemented, but I miss the most important part ...
For example, I have the following router configuration (missing components):
[ { path: '', children: [ { path: 'foo', children: [ { path: 'bar', data: { requiredPermissions: ['a', 'b'] } } ]} ]}, { path: 'baz', data: { requiredPermissions: ['c'] }, children: [ { path: ':id' } ]} ]
Now I would like to ask Router for Route , which will be used if routerLink is /foo/bar or /baz/123 .
I searched for the source code of the Router ( https://github.com/angular/angular/blob/master/modules/%40angular/router/src/router.ts ) but could not find an easy way to do this. Especially how it handles these variables :id .
Of course, I could Router.config over Router.config , deeper and deeper. But then I will have to parse these variables, regular expressions, etc. There should be an easier way, because the angular router must internally do all this too.
Do you have an idea / solution?
angular angular2-routing
Benjamin m
source share