这里我有$scope.content
一段文字。当用户单击下一个按钮时,我会替换$scope.content
文本。
这个文本过渡不是很平滑,所以我想按以下顺序添加一个简单的过渡淡入淡出:
- 用户单击下一步按钮
- 当前
$scope.content
div 将淡出 - 淡出动画完成后,替换
$scope.content
- 然后立即显示新文本(无动画)
angular
.module('app', [])
.controller('Controller', function ($scope) {
var data = [
'Here is slide #1',
'Another slide, it is #2',
'Can I get another? Yep! #3',
'Last but not least, slide #4'
];
$scope.slide = 0;
$scope.content = data[$scope.slide];
$scope.next = function () {
$scope.slide++;
$scope.content = data[$scope.slide];
};
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app" ng-controller="Controller">
<div>{{content}}</div>
<button ng-click="next()">Next</button>
</div>