[英]AngularJS global optional hash parameter
How can I get/check the following url parameters with AngularJS? 如何使用AngularJS获取/检查以下url参数?
public/#/?var=test
public/#/new?var=test
public/#/statistics?var=test
I'm using ng-route
to route /
, /new
, ... to the concerning Controller. 我正在使用
ng-route
将/
, /new
,... ng-route
到有关的Controller。
How can I access the var
parameter in a global controller. 如何在全局控制器中访问
var
参数。 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
: 使用
$location
:
app.module("my-app").controller(["$location", function($location){
this.myVar = $location.search().var;
// or
this.myVar = $location.$$search.var;
}]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.