The AngularJS template can only see what is available in the area, so you need to somehow put $ location service in the area. There is one area that is always available in an AngularJS application called $ rootScope, so it can be used for your use case.
What you can do is use the run () method of the module to output $ location to $ rootScope:
var myApp = angular.module('myApp', []).run(function($rootScope, $location) { $rootScope.location = $location; });
this would make the "location" available in all templates so that later you can do in your template:
Current path: {{location.path()}}
pkozlowski.opensource Aug 13 2018-12-12T00: 00Z
source share