Is there a built-in way to get the current URL without any query parameters?

前端 未结 2 1925
生来不讨喜
生来不讨喜 2021-02-02 09:01

If my URL is http://www.something.com/foo/bar/index.html?color=yellow&animal=rat, it seems as though:

  • $location.path() will return
2条回答
  •  孤独总比滥情好
    2021-02-02 09:45

    As far as I'm aware you have to construct it yourself. Not that you were asking how to construct it, but for those who are wondering:

    var url = $location.absUrl().split('?')[0]
    

提交回复
热议问题