I'm trying to animate a div on click. When i click on a link a div should be appear and that div i clicked disappear. I made an example here:
http://plnkr.co/edit/703244UJ0hcG9GjkOjOz?p=preview
By the way this is some code:
<a class="" ng-click="showDetails" ng-if="!showDetails">
Expand
</a>
<div class="animate-if" ng-if="showDetails">
Details!!
<a style="cursor:pointer;" ng-click="!showDetails">
Close
</a>
</div>
{{showDetails}}
</body>
Angular
var app = angular.module('plunker', ['ngAnimate']);
app.controller('MainCtrl', function($scope, $window) {
showDetails = false;
});
css:
.animate-if.ng-enter, .animate-if.ng-leave {
-webkit-transition: 1s linear all;
-moz-transition: 1s linear all;
-ms-transition: 1s linear all;
-o-transition: 1s linear all;
transition: 1s linear all;
}
.animate-if.ng-enter {
max-height: 0;
opacity: 0;
}
.animate-if.ng-enter.ng-enter-active {
max-height: 999px;
opacity:1;
}
.animate-if.ng-leave {
max-height: 999px;
opacity:1;
}
.animate-if.ng-leave.ng-leave-active {
max-height: 0;
opacity:1;
}
So, when i click "Expand" should be appear the div with class: animate-if and disappear this one:
<a class="" ng-click="showDetails" ng-if="!showDetails">
Expand
</a>
Then, when i click Close should be disappear the div : animate-if and re-appear the link "Expand" again. Of course using the animation. Actually not working. Not appears or disappears.