Skip to content

Instantly share code, notes, and snippets.

@zenius
Created May 31, 2019 11:00
Show Gist options
  • Save zenius/4e71072b3f89f29f08412a41bdce2b42 to your computer and use it in GitHub Desktop.
Save zenius/4e71072b3f89f29f08412a41bdce2b42 to your computer and use it in GitHub Desktop.
In AngularJS, a service is a function, or object, that is available for, and limited to, your AngularJS application.
AngularJS has about 30 built-in services. One of them is the $location service.
The $location service has methods which return information about the location of the current web page:
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $location) {
$scope.myUrl = $location.absUrl();
});
In order to use the service in the controller, it must be defined as a dependency.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment