{{thing.name}}. Then on the edit router I have the following... constructor( privat" /> {{thing.name}}. Then on the edit router I have the following... constructor( privat" /> {{thing.name}}. Then on the edit router I have the following... constructor( privat"/>

How do I know if I need to go back 1 or 2 levels when using Angular Router 3

122 Views Asked by At

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.

0

There are 0 best solutions below