Angular 1 - get current URL parameters

前端 未结 6 1243
情话喂你
情话喂你 2020-11-30 03:37

I want to extract data from current URL and use it in controller. For example I have this url:

app.dev/backend/surveys/2

Bits t

6条回答
  •  半阙折子戏
    2020-11-30 04:16

    Better would have been generate url like

    app.dev/backend?type=surveys&id=2
    

    and then use

    var type=$location.search().type;
    var id=$location.search().id;
    

    and inject $location in controller.

提交回复
热议问题