How can I get/check the following url parameters with AngularJS?
public/#/?var=test
public/#/new?var=test
public/#/statistics?var=test
I'm using ng-route
to route /
, /new
, ... to the concerning Controller.
How can I access the var
parameter in a global controller. I would like to use that optional parameter to show/hide a modal dialog triggered from a global controller. It should be independed of any route.
How can I achieve the goal?
Use $location
:
app.module("my-app").controller(["$location", function($location){
this.myVar = $location.search().var;
// or
this.myVar = $location.$$search.var;
}]);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.