0

Is any way how to access $route inside directive function?

What I basically want is to know the current templateUrl, say:

app.directive("scrollable", function ($document) {
    return {
        restrict: 'A',
        link: function (scope, element, attrs) {
            $document.bind('scroll', function (evt) {
                 console.log($route.current.templateUrl); // $route is undefined!
            });
        }
    };
});

P.S. I am newbie in the AngularJS, don't be so rigorous :)

Andremoniy
  • 32,711
  • 17
  • 122
  • 230

1 Answers1

5

I think you need to inject the $route to the directive

app.directive("scrollable", function ($document,$route) {
Sachila Ranawaka
  • 31,266
  • 5
  • 51
  • 75