Reputation: 1417
In AngularJS we do (with ui-router) when define a state:
.state('myState', {
url: 'some-user-friendly-url'
...
})
So we have a way to set url
and name
. It's nice to have so we don't worry about url and remember only state name when we want to use $state.go('myState')
.
I'm getting started with Angular, but in its native router there is path
that is used with routerLink
directive to go to a route and in the same time use it as the url.
Does the native router have a solution for that case? Or it's again better to go with UI-router for Angular?
Upvotes: 0
Views: 271
Reputation: 14574
The Angular(2+) Router doesn't have named states - the same thing you would do with UI-Router of saying $state.go(<some state name>)
, you would do with the Angular Router by using router.navigate(<some path>)
. My personal recommendation would be to try the Angular Router to see if you actually miss those named states. UI Router served a real need with AngularJS since the default router was so limited. The new Router learned a lot from UI Router (and other Routers) and is much more capable, so I would suggest trying it out to see if it serves your needs.
But, you can also use UI Router as well in Angular, if you must have your states.
Upvotes: 1