O'Reilly logo

Mastering Web Application Development with AngularJS by Pawel Kozlowski, Peter Bacon Darwin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the $location service

AngularJS provides an abstraction layer over URLs (and their behavior) in the form of the $location service. This service masks the difference between the hashbang and the HTML5 URL modes allowing us, application developers, to work with a consistent API regardless of the browser and the mode being used. But the $location service does more heavy lifting, by providing the following functions:

  • Provides convenient, clean API to easily access different parts of the current URL (protocol, host, port, path, query parameters, and so on)
  • Lets us to programmatically manipulate different parts of the current URL and have those changes reflected in the browser's address bar
  • Allows us to easily observe changes in different components ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required