डाउनलोड पी.डी.एफ. ई-बुक्स
AJS - Services $location

$location service; ये Object; window.location इस object जैसा होता है | ये object; location के बारे में सभी information को methods के माध्यम से प्राप्त करता है |


Example for $location Service in AngularJS

Source Code :
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
</head>
<body>

<div ng-app="app" ng-controller="ctrl">
$location.absUrl() :{{absUrl}}<br />
$location.hash() :{{hash}}<br />
$location.host() :{{host}}<br />
$location.path() :{{path}}<br />
$location.port :{{port}}<br />
$location.protocol() :{{protocol}}<br />
$location.search :{{search}}
</div>

<script>
var myapp = angular.module("app",[]); 
myapp.controller("ctrl", function($location,$scope){  
	$scope.absUrl = $location.absUrl();
	$scope.hash = $location.hash();
	$scope.host = $location.host();
	$scope.path = $location.path();
	$scope.port = $location.port();
	$scope.protocol = $location.protocol();
	$scope.search = $location.search();
});
</script>

</body>
</html>
Output :
$location.absUrl() :{{absUrl}}
$location.hash() :{{hash}}
$location.host() :{{host}}
$location.path() :{{path}}
$location.port :{{port}}
$location.protocol() :{{protocol}}
$location.search :{{search}}