AngularJS While adding the location parameter, it should support the previously inserted
When I add a parameter using $ location in the url as below, it removes the added data first, but I want to keep the 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 just changes url to this,
http: // localhost / angular_laravel / angjs / # / bag_list? category = 1
now when the following function does 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 TO LIKE: http: // localhost / angular_laravel / angjs / # / bag_list? Model = 1 & category = 1
My problem is that it removes the previous setting, but I want to keep this setting,
any help ... ??
source to share
You have 2 options which I believe.
If you are only setting one value (as shown in the example), you can use form 2 of the setter argument. eg.
$location.search('model', model_search);
If you need to set more than 1 (or your data is already coming in as an object), you can manually concatenate the values. eg.
$location.search(angular.extend({}, $location.search(), { model: model_search }));
source to share