【发布时间】:2015-07-01 21:43:57
【问题描述】:
在我的代码中,我试图创建多个 div,其中包含一个隐藏按钮。单击此按钮时,相应的 div 应该消失,并且它下面的 div 应该出现在顶部(即它们应该通过一些动画填充消失的 div 创建的空间)。
这是我的html代码:
<body ng-app="task" ng-controller="repeat">
<div ng-repeat='x in array' ng-hide="x.show">
<p>{{ x.text }}
</p>
<button ng-click="toggle($index)">Hide</button>
</div>
</body>
我的 js 文件包含以下内容:
var app = angular.module('task');
app.controller('repeat',function($scope){
$scope.array = [{
show: true,
text:'Sample Text 1'},
{
show: true,
text:'Sample Text 2'},
{
show: true,
text:'Sample Text 3'}];
$scope.toggle = function(){
$scope.array[index].show = false ;
};
})
在我的 css 中,我有以下代码:
.ng-hide-add { animation:1s fade ease; }
@keyframes fade{
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
我查看了很多发布在网上的滑块动画,并试图将它们调整到我的程序中,但直到现在都失败了。
你能告诉我应该添加什么代码来使动画成为可能吗?非常感谢您的回复。
【问题讨论】:
标签: javascript css angularjs animation ng-repeat