Reputation: 4161
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...??
Upvotes: 3
Views: 61
Reputation: 9072
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 }));
Upvotes: 3
Reputation: 1219
Try:
$location.path('/bag_list').search({category: cat_search, model: model_search});
Upvotes: 0