Something along the lines of: link: function($scope, element, attrs, $location) {
Is this possible?
See Question&Answers more detail:osSomething along the lines of: link: function($scope, element, attrs, $location) {
Is this possible?
See Question&Answers more detail:osIn the declaration of the directive, inject the location service.
app.directive('myDirective', ['$location', function($location) {
return {
link: function(scope, elem, attrs) {
// path() and url() can be used as getters or setters
console.log($location.url());
console.log($location.path());
}
};
}]);
If you are attempting to get the current location, use location.path()
or, alternatively, use the $route
service.
Information on both: