0

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?

1
  • $location is what you're looking for . Commented Jan 24, 2016 at 15:11

1 Answer 1

1

Use $location:

app.module("my-app").controller(["$location", function($location){
  this.myVar = $location.search().var;
  // or
  this.myVar = $location.$$search.var;
}]);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.