1

Is there a way setting multiple query parameters of the same key using $location.path.search

i.e. /categloue?cat=tents&cat=fourperson

It only uses the last item..

$location.path('/categloue').search({ cat: 'tents', cat: 'fourperson' })

gives

i.e. /categloue?cat=fourperson

3 Answers 3

3

Generally if your query string contains multiple items of the same key, it's considered an array. So in your situation, this should work:

$location.path('/categloue').search({ cat: ['tents', 'fourperson'] })
Sign up to request clarification or add additional context in comments.

Comments

1

You can do it the way you are describing, but you'd need to set different keys! In your code, you are defining the same key twice.

You could try:

$location.path('/categloue').search({ cat: "tents", subcat: "fourperson" })

1 Comment

Hi Johnny, thanks for your reply, unfortunately as there are 200+ filters and you can use a combination of filters at one time and on multiple levels it's been set up with multiples of the same keys which is interpreted server side.
0

The solution I used was to create the query's as a string and pass them into just the $location.url

var area = '?cat=tents' + '&cat=fourperson';
$location.url('/en/tiles' + area)

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.