3

When i add parameter using $location in url as shown below it first removes added data but i want to keep that previous data...

Example with code

Main url: http://localhost/angular_laravel/angjs/#/bag_list

when i do this,

$location.path('/bag_list').search({category: cat_search});

it simply changes url to this,

http://localhost/angular_laravel/angjs/#/bag_list?category=1

now when next function doing something like this,

$location.path('/bag_list').search({model: model_search});

and then url changes to this,

http://localhost/angular_laravel/angjs/#/bag_list?model=1

but i want to keep both like this,

I WANT LIKE THIS: http://localhost/angular_laravel/angjs/#/bag_list?model=1&category=1

My problem is that it deletes previous parameter but i want to keep that parameter,

any help...??

2 Answers 2

3

You have 2 options I believe.

If you are only setting a single value (as you are in the example) you can use the 2 argument form of the setter. eg.

$location.search('model', model_search);

If you need to set more than 1 (or your data is coming in as an object already) you can manually merge the values. eg.

$location.search(angular.extend({}, $location.search(), { model: model_search }));
Sign up to request clarification or add additional context in comments.

1 Comment

$location.search(angular.extend({}, $location.search(), { model: model_search })); it make a huge sense about my programming life
0

Try:

$location.path('/bag_list').search({category: cat_search, model: model_search});

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.