我想用animate.css和angular来动画显示和隐藏元素。angular ngShow with animate.css
我已阅读this SO question和ngShow
和ngAnimate
的角度文档,但仍无法使其正常工作。
我已经尝试了下面的安装程序,但它不起作用。
app.js
var app = angular.module('plunker', ['ngAnimate']);
app.controller('MainCtrl', function($scope) {
$scope.show = true;
});
的index.html
<body ng-controller="MainCtrl">
<p>Show: {{show}}</p>
<div class="show" ng-click="show = !show" ng-show="show === true">Show is true</div>
<div class="hide" ng-click="show = !show" ng-show="show === false">Show is false</div>
</body>
的style.css
.show.ng-hide-add {
animation: fadeOut 5s linear;
}
当“秀点击是真的“(因此隐藏它)我看到它隐藏之前等待5秒,所以有发生,但它不会淡出。
我可以做,如果我添加此的CSS它的工作:
.show.ng-hide-add {
opacity: 1.0;
display: block !important;
transition: opacity 1s;
}
.show.ng-hide-add-active {
opacity: 0;
}
不过,我不想做这样。我想用animate.css's keyframes(我认为这是正确的说法,我的CSS行话不艳)如fadeIn
,fadeOut
等。
plunker展现我所看到的。
我在做什么错?我如何使用角度为ngAnimate
的animate.css的关键帧动画?
我能够得到它的工作,如果我使用我张贴的第二段代码添加我自己的CSS转换。 *然而*,我在我的问题中说过我想使用animate.css关键帧动画。 'fadeIn','zoomOut'等。我将编辑我的问题,尝试使它不那么混乱。抱歉。 –
@MattLishman:查看我答案中的编辑,并告诉我它是否适合你。我也更新了Plunker的例子。 – fbid
啊!在你的plunker中,你使用了不同于我的animate.css版本。使用相同的版本(使用plunkers库功能,由于某种原因,我没有将它用于animate.css ...),我的原始代码有效。所以你以不同的方式回答了我的问题。虽然你的答案对其他人仍然有用,但如果你想将其添加到你的答案中,我可以接受它。 –