How to use Angular $location to set my new url location by changing its key-value params dynamically?

前端 未结 3 610
臣服心动
臣服心动 2020-12-28 18:30

Let\'s say I have a RESTful endpoint that accepts a range of facets to query data. Here\'s a few examples:

example.com/search?type=Doctor&location=Boston         


        
3条回答
  •  死守一世寂寞
    2020-12-28 19:03

    In fact, instead of using $location to call your data-service endpoint, a normal way to do that is

    and in getDataService() do a

    $http.get( serviceUrl, config ).success( ...
    

    with your serviceUrl being

    example.com/search/Facility/Wayne,NJ/3/f
    

    after parsing (using sprintf)

提交回复
热议问题