How to get current url path in Angularjs

How to get current url path in Angularjs

In this Post We Will Explain About is How to get current url path in Angularjs With Example and Demo.Welcome on – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Angularjs get current url path Example

In this post we will show you Best way to implement Angularjs get current url parameters, hear for Angular Get Current Route using the Location Service with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Also Read :   AngularJS Custom scrollbar Directive Example - ngscrollbar Example

Syntax of AngularJS $location Service

var app = angular.module('liveApp', []);
app.controller('live24uCtrl', function ($scope, $location) {
$scope.liveweburi = $location.absUrl();

AngularJS $location Example

<!DOCTYPE html>
<title>AngularJs Simple $location Service with Example</title>

<script src="1.4.8/angular.min.js"></script>

<script type="text/javascript">
var liveApp = angular.module('liveApp', []);
liveApp.controller('live24uCtrl', function ($scope, $location) {
$scope.liveweburi = $location.absUrl();
$scope.myhostname = $;
$scope.webportno = $location.port();
$scope.livewebprotocol = $location.protocol();
<div ng-app="liveApp" ng-controller="live24uCtrl">
<p>AngularJs Url of Webpage: {{liveweburi}}</p>
<p>Host of Webpage in AngularJs: {{myhostname}}</p>
<p>AngularJs Port of Webpage: {{webportno}}</p>
<p>Angular Protocol of Webpage display: {{livewebprotocol}}</p>


This contains our simple custom index.js files Add Like as javascript, Angular scripts

var livebase = $location.absUrl().length - $location.url().length;
function getPath(fullUrl) { 
    return fullUrl.substring(livebase);

We can use simple $location.absUrl().

  $scope.$on('$locationChangeStart', function(e) {
      if (meetsTheRequirementsToLeave()) {
      var livePath = $location.path();
      checkIfUserWantsToLeave().then(function() {

You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example

Also Read :   Angularjs Show Hide Password in Password TextBox with CheckBox


I hope you have Got What is Angular Get Current Route using the Location Service And how it works.I would Like to have FeedBack From My Blog( readers.Your Valuable FeedBack,Any Question,or any Comments about This Article( Are Most Always Welcome.