December 2014
Intermediate to advanced
272 pages
8h 17m
English
The $location service provides a wrapper to the JavaScript window.location object. This makes the URL accessible in your AngularJS application. Not only can you get information about the URL, but you also can modify it, changing the location with a new URL or navigating to a specific hash tag.
To add the $location service to a controller or service, you simply need to inject it using the standard dependency injection methods. For example:
app.controller('myController', ['$scope', '$location', function($scope, location) { . . . }]);
Table 9.5 lists the methods that can be called on the $location service and describes their implementation.
Table 9.5 ...
Read now
Unlock full access