0

I want to use $location to change url search parameter. For example:

I have a url, example.com/path?id=12345&target=_self

how could I use $location to change the url to

example.com/path?id=54321&target=_blank

When I use $location.search({id: '54321', target='_blank'}), it just append a

new parameter to the end of url instead of change the url.

Thanks.

Nicolas Z
  • 47
  • 4

2 Answers2

0

Angularjs $location documentation says that you have to write this like below:

$location.search('id', '54321')
         .search('target', '_blank');
Onur Gazioğlu
  • 501
  • 2
  • 12
  • Thanks, use this method is the same, just append a new search after the previous url instead of changing current url search. – Nicolas Z Oct 13 '16 at 15:39
0

I guess you should refer to this Stackoverflow post.

Hope this helps you. Thanks.

Community
  • 1
  • 1
Denver Gomes
  • 44
  • 1
  • 12
  • Thanks, use this method is the same, just append a new search after the previous url instead of changing current url search. – Nicolas Z Oct 13 '16 at 15:39