I had the following code <a routerLink="./edit/{{thing.name}}">{{thing.name}}</a>
. Then on the edit router I have the following...
constructor(
private route: ActivatedRoute
) {
// If we have a param the close link goes back 2 level, otherwise it is 1
this.route.params
.map(params => params['name'])
.subscribe((id) => {
if(id){
this.closeLink += "../"
}
});
...
}
I noticed that I could change the original HTML to <a [routerLink]="['edit', {name: thing.name}]">{{thing.name}}</a>
. However, now the url changes to ../thing/edit;name=asdsadsa
instead of /edit/asdsadsa
. Both of these urls work but the later needs to go back 2 levels where the former needs to go back 1. Is there a router service or something I can use to tell how many levels I need to go back. This is bound to get dynamic and I am not sure I will always know thing
.