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
  • 34,031
  • 20
  • 135
  • 241

1 Answers1

5

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

app.directive("scrollable", function ($document,$route) {
Sachila Ranawaka
  • 39,756
  • 7
  • 56
  • 80