Animate.css and Angularjs ng-hide

Miguel-.o picture Miguel-.o · Jun 24, 2014 · Viewed 12.1k times · Source

I am learning and experimenting with Angularjs and animate.css. I am trying to add animations when the ng-show is true or false. The showing and hiding works but not the animations. Hope someone here can show me what I am doing wrong.

Here is the plunk.

thanks for the help.

Answer

wizeowl picture wizeowl · Oct 10, 2014

Here's a slightly modified version of your code with ng-show and animate.css working together.

HTML

<div ng-controller="controller">
  <button ng-click="showme = !showme">Show or Hide</button>
  <div ng-show="showme" class="boxme">
    <h2>Box to Show and Hide</h2>
    <p>Show and hide this box using animate.css the angularway!</p>
  </div>
</div>

JavaScript

(function() {
    var app = angular.module("theapp", ['ngAnimate']);
    var controller = function($scope){
        $scope.showme = false;
    };
    app.controller("controller", controller);
}());

CSS

.boxme.ng-hide-add {
    -webkit-animation: fadeOutLeftBig 0.4s;
    display: block!important;
}
.boxme.ng-hide-remove {
    -webkit-animation: fadeInLeftBig 0.4s;
}

http://jsfiddle.net/h58wsxcw/

Note the options on the left (body tag, external resources) that have to be set to get angular up and running on jsfiddle.