ng-repeatを使用して配列から項目を返すことができるようにしたい。3秒ごとに配列の項目を返すng-repeatを行う方法
アニメーションエフェクトは、前のアイテムの3秒後に表示されるアニメーションエフェクトです。
ここでは、遅延が3秒後に結果を返すng-repeatの例を示します。 http://jsfiddle.net/98rbe9hc/
<div ng-controller="MyCtrl">
<ul>
<li ng-repeat="phone in phones | filter:delay_filter">
<span>Name : {{phone.name}}</span>
</li>
</ul>
</div>
var myApp = angular.module('myApp',[]);
//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});
myApp.controller('MyCtrl', function($scope, $timeout) {
var delayed = false;
$scope.phones = [
{ name: 'Motorola' },
{ name: 'Nokia' },
{ name: 'Ericsson' }
];
var delayInMilliseconds = 3000;
var doneWaiting = false;
$scope.delay_filter= function(item){
return doneWaiting;
};
$timeout(function() {
doneWaiting = true;
}, delayInMilliseconds);
});
しかし、私はしたいが、前の項目の後に3秒を表示する配列内の各アイテムのためです。
よく機能します。 20の結果を言わせて結果を止めることは可能ですか? –
私はそれがscopeの長さによって動的になると思います.phones –
@ ObasiObenyOjこれを行うには、間隔をキャンセルするif文に2番目の条件を追加します。したがって、 '$ scope.count> = $ scope.phones.length || $ scope.count == 20' –