Filippo oretti
Filippo oretti

Reputation: 49817

AngularJs ui-router $location or $state?

How can I transform this:

$location.path('/app/home/' + id).search({x:y});

to this:

$state.go('/app/home/' + id).search({x:y});

I tried, but I actually can't get enough information how to achieve that...

Upvotes: 2

Views: 15483

Answers (1)

Radim Köhler
Radim Köhler

Reputation: 123861

There is nice documentation (while deprecated, still really clear):

$state.go(to [, toParams] [, options])

Let's say that the state definitions are looking like this:

.state('app', { // parent app
  url: '/app',
  ...
})
.state('app.home', {
  url: '/home/:x',         // the param named x
  ...

Then you will do

$state.go('app.home', {x:y});

This Q&A could help as well:

Upvotes: 11

Related Questions