title: Scroll to Top of the screen not working from Link in Directive
body: <p>I can't make this scrolling with animation working from my simple component, and I would like to understand why!</p>
  
  <p>Basically this is my simple code:</p>
  
  <pre><code>(function(angular) {
    var app = angular.module('pi.core');
    app.directive('piGoUp', function() {
      return {
        restrict: 'E',
        replace: true,
        transclude: true,
        scope: {
          classes: '@',
          image: '@'
        },
        link: function(scope, element, attrs) {
          if (!scope.image) scope.image = 'go-up.svg';
  
          $(document).ready(function() {
            $(window).scroll(function() {
              if ($(this).scrollTop() &gt; 250) {
                $('#scrollup').fadeIn(300);
              } else {
                $('#scrollup').fadeOut(300);
              }
            });
  
            $('.pi-go-up').click(function() {
              console.log('ciao');
              $('html, body').animate({ scrollTop: 0 }, 1000);
              return false;
            });
          });
        },
        template:
          '&lt;div class="pi-go-up {{classes}}"&gt;&lt;div class="pi-go-up-text" ng-transclude&gt;&lt;/div&gt;&lt;div&gt;&lt;img src="{{image}}"/&gt;&lt;/div&gt;&lt;/div&gt;'
      };
    });
  })(angular);
  </code></pre>
  
  <p>With the CSS, in case it's relevant for the missing behaviour:</p>
  
  <pre><code>.pi-go-up {
    display: inline-flex;
    float: right;
    vertical-align: middle;
    margin-top: 20px;
    margin-bottom: 20px;
  }
  .pi-go-up-text {
    font-size: 16px;
    line-height: 1.38;
    letter-spacing: 0.1px;
    color: #575757;
    margin-top: auto;
    margin-bottom: auto;
  }
  .pi-go-up img {
    width: auto;
    height: 36px;
    margin-left: 11px;
  }
  </code></pre>
  
  <p>I am following this <a href="http://redvinestudio.com/how-to-add-a-scroll-to-top-link-to-your-website/" rel="nofollow noreferrer">guide</a> with a working demo.</p>
  
  <p>Any idea about how I can make it working? I tried in several ways, but I would like to keep it inside the directive.</p>