Imran Imran - 14 days ago 10
Javascript Question

Angularjs querySelector find element based on property

I tried to find if angularjs can do like below:

angular.element(document.querySelector('.content-here').find('div.offsetTop=8');


Can someone help me? You can see my plunker here.

Answer

Edited:
You could make a directive if you do not wish to specify one by one. Also, remove the unecessary code in the controller. Plunker here

  .directive('animateFromLeft', function() {
      return {
        restrict: 'AE',
        link: function(scope, elem, attr) {
          var children = elem.children();
          children.addClass('animated fadeInLeft');

          var animationDelay = 0;
          for(var i = 0; i < children.length; i++) {
            children[i].style.animationDelay = animationDelay.toString() + 's';
            animationDelay += 1;
          }

          $compile(elem)(scope);
        }
      };
    });

========================================================================

I think you are doing it in hard way. I assume that you will not be using ng-repeat and based on your scenario you can specific the animation delay one by one.

Plunker here

<div class="content-here">
      <div class="animated fadeInLeft" style="animation-delay: 0s">1</div>
      <div class="animated fadeInLeft" style="animation-delay: 1s">2</div>
      <img class="animated fadeInLeft" style="animation-delay: 2s" width="100px" src="https://staticdelivery.nexusmods.com/mods/110/images/74627-0-1459502036.jpg" />
      <div class="animated fadeInLeft" style="animation-delay: 3s">3</div>
      <div class="animated fadeInLeft" style="animation-delay: 4s">4</div>
    </div>