【发布时间】:2014-07-22 20:11:21
【问题描述】:
鉴于此模板:
<div fade>
<h2>
TEST {{ headline.Title }}
</h2>
</div>
还有以下指令: 如何更改此指令以使用内置 angular 动画替换 jquery 淡入淡出?
我需要文本淡出、被替换,然后淡入。
newman.directive('fade', ['$interval', function($interval) {
return function ($scope, element, attrs) {
$scope.index = 0;
$scope.news = $interval(function () {
// REPLACE JQUERY BELOW
$(element).fadeOut('fast', function() {
$scope.index = $scope.getValidNewHeadlineIndex();
// view is currently correctly updated by the line below.
$scope.headline = $scope.headlines[$scope.index];
$(element).fadeIn('slow'); // REPLACE JQUERY HERE TOO!
});
}, 10000);
}
}]);
【问题讨论】:
-
您是否将 ng-animate 添加到 angular.module 中?
-
我已将问题更改为更简洁(我希望如此)。使用可以更改为使用 CSS / AngularJS 的 jQuery 示例。周围有一些例子,但我找不到在两个动画之间挤压视图变化的例子。淡出、更改视图、淡入...
-
我真的希望这会被抢走并迅速回答。有没有人对编辑问题有一些建议,以使其对经验丰富的 angularjs 编码员更具吸引力......