Marin Petkov
Marin Petkov

Reputation: 2158

Deeplinks with Angular 2?

I've had this problem since Angular 1 and was really hopefull that it would be solved in Angular 2: support fo deeplinks. Both versions of Angular have a router which is meant to show completly different states of a page. This works when its just 1 parameter at a time, but what happens when you have 20 different params you want to show for one page? So here is an example of a deeplink I want to achieve:

angular-app.com/#type=1&form=a&blah=blah&size=40

Currently, I wrote my own service that basically has a set and get function that parses the window.location.hash to read the settings and also updaates it when a param has changed. This works fine but it is written in pure javascript. So I am wondering if there is a native way to do it with Angular2?

Upvotes: 2

Views: 446

Answers (1)

Mark Pieszak - Trilon.io
Mark Pieszak - Trilon.io

Reputation: 66961

There is currently a new router that came out a few days ago that is in alpha state as of 6/16/16, but it will be the new default router for Angular2. You can read more about it here: Angular2 Router-3

You can install it with npm by the package: @angular/[email protected]

But one of the many new features it will have (that modern routers need, like you said) is deep-linking.

Here's a plunkr example of it in action

Upvotes: 2

Related Questions