2

I have an array of user ids. I want to pass user ids to $location.search

$scope.userIds = [1, 2];
$location.search({'userId[]' : $scope.userIds}).path('/search');

It give a URL

/search?userId%5B%5D=1&userId%5B%5D=2

if I remove %5B%5D unwanted chars then it works

How to remove them?

3
  • I think I asked wrong question. It is working with $location.search but see updated answer Commented Oct 5, 2015 at 9:11
  • 1
    Try removing the "[ ]" like so: $location.search({'userId': $scope.userIds}).path('/search') Commented Oct 5, 2015 at 9:33
  • 1
    Previously was not working :O Now worked :'D Commented Oct 5, 2015 at 10:25

1 Answer 1

4

To eliminate the unwanted characters Try removing the "[ ]" like so:

$location.search({'userId': $scope.userIds}).path('/search')  

hope it helps

Sign up to request clarification or add additional context in comments.

Comments

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.