Mick
Mick

Reputation: 8913

Angular 2 router without route changes / history

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?

Upvotes: 0

Views: 458

Answers (1)

mickdev
mickdev

Reputation: 2885

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...

Upvotes: 1

Related Questions