1

I was reading that routerlink implicitly calls relativeTo whereas this.router.navigate doesn't.

Knowing this info, I still can't seem to make the below work.

The routerlink works and gives me the following address:

http://localhost/main/(aux:crypto/5a599f35af967b0017d1be6f/blogoutlet:steemblog:)

But:

 this.router.navigate([{outlets: { 'blogoutlet' : ['steemblog']}}])

only gives:

http://localhost/main/(aux:crypto/5a599f35af967b0017d1be6f)

Everytime I am trying to change these paths I struggle to understand what is going on and it takes me ages to work it out. Is there a simple rule to it that I can follow?

oudekaas
  • 325
  • 1
  • 6
  • 21

1 Answers1

2

[routerLink] can be used in html for or elements. This will navigate to the path created with params given to routerLink.

this.router.navigate(['/detail', this.selectedHero.id]);

is used in your component.ts or services to navigate to particular component provideed in path.

Sajeetharan
  • 216,225
  • 63
  • 350
  • 396
  • but how do I make this.router.navigate route to the same path as the routerlink? I notice I forgot to add the routerlink which points to the same path, but doesn’t work. Should I use something lije: router.navigate ([‘../‘, {outlets: {‘blogoutlet’:[‘Steemblog’]}}]) – oudekaas Jan 13 '18 at 08:03
  • you need to provide the .navigate with the relative path – Sajeetharan Jan 13 '18 at 08:03
  • y I struggle to understand what the relative path means and how to add it, I tried the relative path, but with relativepath this.route it didn’t wokr – oudekaas Jan 13 '18 at 08:06
  • https://stackoverflow.com/questions/21306512/difference-between-relative-path-and-absolute-path-in-javascript – Sajeetharan Jan 13 '18 at 08:08
  • thnak u so much I will mark that as the answer, could I ask u to take a look at: https://stackoverflow.com/questions/48227043/angular-5-docker-nginx-reverse-proxy-trying-to-be-in-development-mode-ng-serve – oudekaas Jan 13 '18 at 08:11
  • Ok let me check – Sajeetharan Jan 13 '18 at 08:40