$location Service In AngularJS

  1. <!DOCTYPE html>  
  2. <html>  
  3. <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>  
  4. <body>  
  5.   
  6. <div ng-app="myApp" ng-controller="myCtrl">  
  7. <p>The url of this page is:</p>  
  8. <h3>{{myUrl}}</h3>  
  9. </div>  
  10.   
  11. <p>This example uses the built-in $location service to get the absolute url of the page.</p>  
  12.   
  13. <script>  
  14. var app = angular.module('myApp', []);  
  15. app.controller('myCtrl', function($scope, $location) {  
  16.     $scope.myUrl = $location.absUrl();  
  17. });  
  18. </script>  
  19.   
  20. </body>  
  21. </html>