0

I like the benefits of the Angular 2 Router like Guards, Resolver, using navigateTo etc.

But in my app i dont want to change the route at all. So it should always stay "/" without changes in browser history. Is that possible?

Mick
  • 8,203
  • 10
  • 44
  • 66

1 Answers1

1

It's possible, but in this case, you can't use routerLink in your templates.

You can use instead user interaction within your app to trigger events (click)="announce(this)" or (keyup)="execute(that)"

Put in your routing configuration :

{ path: '**', redirectTo: '' } //redirect all path to your home page

Some remarks about that:

  • Users can't access deep links (i.e: yourapp.com/awesome-article-1)
  • You'll have some seo issues with search engines bots...
mickdev
  • 2,765
  • 11
  • 15
  • But i do have important routes with guards etc. I just dont want them to show up in browser bar. – Mick Jan 20 '17 at 21:52