0

In angularjs, do we have anything on app.js level to determine the application URL.

I know inside the application, we can use $location.path() to determine it, but app.js we dont have $location

Basically, the need is to enable and disable the console logging for the application using a URL param switch.

Idea is

http://www.test-website.com/ - Will run and not fetch console.log

http://www.test-website.com?debug=1 - Will run and fetch console.log (s) for the application.

Thanks in advance!!!

2
  • you can use $location in any function that includes it as a dependency. Without any code, it's hard to know what you are doing, but there is no reason why $location would not be available to code inside an app.js file. Commented Mar 11, 2015 at 11:04
  • What is your question? Commented Mar 11, 2015 at 11:46

2 Answers 2

1

You can always in javascript - in a browser - call window.location. It will return an object that holds the hostname, pathname, port and protocol - amongst other properties and methods.

Calling window.location.search will return "?debug=1" in your case.

Sign up to request clarification or add additional context in comments.

Comments

0

You can't use $location service in app.config() block but you can use it in app.run() which can also be present in app.js.

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.