with $location.search(): how to remove a parameter from the url when it's null

前端 未结 3 1053
长发绾君心
长发绾君心 2021-02-06 20:57

$location.search() to set an url

the search parameter which is passed to the search() is set by a form. selecting and deselecting an element ca

相关标签:
3条回答
  • 2021-02-06 21:38

    You can use $location.search({}) to clear all at once.

    0 讨论(0)
  • 2021-02-06 21:40

    You can also do:

    var search = $location.search();
    if (search.parameter == 'null') {
      $location.search({'parameter': null});
    }
    
    0 讨论(0)
  • 2021-02-06 21:45

    Using the $location service, you can remove the search param by assigning it a null value:

    In the case when your parameter is null, in your case 'parameter' you can remove it from the url by assigning it a null value like;

    $location.search('parameter', null);
    

    Hope it helps.

    0 讨论(0)
提交回复
热议问题