1

it's possible to specify to $location.search to send parameters with slashes in url ?

Here is my state:

.state('home/room', {
                url: '/:home_id/:room_id',
                templateUrl: 'home/layout.html'
            });

Using links it works perfectly:

<a ui-sref="home/room({home_id:20, folder_id: 608})"> // I get url: "/20/608" 

Is it possible to do the same thing with $location.path ?

I tried this but it doesn't work.

$location.path("home/room({home_id:20, room_id: 608})")

$location.search({home_id: 20, room_id: 608});

I get /?home_id=20&room_id=608

But I would like /20/608

I'm trying to avoid using regex. Any idea ? Thanks

1 Answer 1

3

The feature you are using is specific to angular-ui-router. To get the URL to be correct using $location you can do string concatenation to build the URL.

$location.path("home/room"+homeId+"/"+roomId);

It is recommended use the angular-ui-router function of $state.go() to transistion between states when using angular-ui-router and $stateProvider

$state.go('home/room',{home_id:20, folder_id: 608});
Sign up to request clarification or add additional context in comments.

1 Comment

see also: ui-sref directive

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.