title: Angular - Jquery Sprite switch animation stops working when using ng-view
body: <p>I have a sprite animation that switches to the next sprite animation after the animation has finished playing. </p>
  
  <p>I made the switch initially using Jquery, but now that I have been implementing Angular's Routing all of my Jquery has stopped working. </p>
  
  <p>I looked it up and found that it might be the wrong order of scripts in my HTML, but when I tried moving Jquery above the AngularJs Script it did not solve the issue.</p>
  
  <p>I looked into it further and found that I will need to change my Jquery into an AngularJS Directive. How do I even go about doing that??</p>
  
  <p>Every site that has tried explaining how it is done, just shows the before and after code. It does not make much sense to me. Can someone show me how this would be done?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>//This is my original Jquery code that I was using. That I want to make work using the Directive
  
  // $(document).ready(function(){
  //     $(".hero-unit.land-animation").one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){ 
  //        $(this).addClass("land-animation2");
  //    });
  // });
  
  
  
  
  // This is what I attempted at trying to do in Angular.
  
  var app = angular.module('app', ['ui.boostrap', 'ngRoute']);
  
  app.directive('directiveName', function() {
    return {
      restrict: 'A',
      link: function(scope, element, attrs) {
        $(element).
        'pluginActivationFunction' (scope.$eval(attrs.directiveName));
      }
    };
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>/* SCSS */
  
  @mixin animation($str) {
    -webkit-animation: #{$str};
    -moz-animation: #{$str};
    /* -ms- prefix removed! */
    -o-animation: #{$str};
    animation: #{$str};      
  }
  
  .land-animation {
      width: 700px;
      height: 493px;
      background: url('../images/front-animation.jpg') left center;
      animation-delay: 0.1s;
      z-index: 10;
      @include animation(play 4.0s steps(48));
  
  }
  
  @include keyframes(play) {
      100% { background-position: -33600px; }
  }
  
  
  .land-animation2 {
      width: 700px;
      height: 493px;
      background: url('../images/front-animation2.jpg') left center;
      @include animation(play2 4.0s steps(48) infinite);
      z-index: 10;
  }
  
  @include keyframes(play2) {
      100% { background-position: -33600px; }
  }
  
  .hero-unit {
      margin: 70px auto;
      display: inline-block;
      position: relative;
      
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"&gt;&lt;/script&gt;
  &lt;script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular-route.js"&gt;&lt;/script&gt;
  
  &lt;!--ANIMATION --&gt;
  &lt;div class="col-sm-12 col-md-4 col-lg-7"&gt;
    &lt;div class="directiveName hero-unit land-animation hidden-md hidden-sm hidden-xs"&gt;&lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>