Dylan Anlezark
Dylan Anlezark

Reputation: 1267

Angular Single url used for all routing?

Here is my apps home page url: http://localhost:4200/ Whenever the user selects a next button a new screen loads with a new url similar to the examples shown below:

http://localhost:4200/screen/static/text/1/0

http://localhost:4200/screen/activity/click-and-reveal/1/1

http://localhost:4200/screen/activity/click-and-reveal/3/2 and so on

I would really like the url to display a single value something like http://MyProjectName ..... as i think it looks rather unprofessional to have the url looking the way it is looking currently.

Any help as to how i could accomplish this would be greatly appreciated :).

Upvotes: 1

Views: 155

Answers (2)

frido
frido

Reputation: 14109

The URL won't change if you use the navigation option SkipLocationChange on your links.

<a routerLink="/somePath" skipLocationChange>Settings</a>

Or in code behind:

this.router.navigate(['/somePath'], { skipLocationChange: true });

Upvotes: 1

blazehub
blazehub

Reputation: 1960

Their are few ways to achieve it:-

  1. Redux
  2. Shared Observable

Upvotes: 0

Related Questions