$location.search() to set the url
the search parameter that is passed to search() is set by the form. selecting and deselecting an element causes some null parameter value, so the URL looks like this:
myapp.com/search?type=text¶meter=null
therefore, I would like to remove these "null" parameters from the url. The documentation has a "paramValue" that can be passed as the second parameter in .search (search, paramValue): if null , the parameter will be deleted.
but i cant do this job ... any suggestion?
edit:. This solution is based on @BKM's explanation.
to remove all parameters that are null , you must go through all of them and test each of them as follows:
for (var i in search) { if (!search[i]) $location.search(i, null); } $location.search(search);
angularjs
FranΓ§ois Romain Sep 02 '13 at 0:59 2013-09-02 00:59
source share