如何使用 Angular 动画进行无限旋转?

How to make an infinite rotation with Angular animations?

我需要一个div无限旋转。 所以,我创建了这个动画:

animations: [
    trigger('rotate', [
        transition(':enter', [style({transform: 'rotate(-360deg)'}), animate('2000ms')])
    ])
]

它旋转,但在 2 秒后停止。这是逻辑。但是我怎样才能使旋转无限大呢?

animation-iteration-count 属性 在 Angular 6 中不受支持。有一个未解决的 GitHub 问题请求支持。

https://github.com/angular/angular/issues/20621

您可以在 CSS.

中轻松定义 无限 动画

https://developer.mozilla.org/en-US/docs/Web/CSS/animation-iteration-count

有人创建了如何使用回调 Angular 制作无限动画的演示。

https://angular-animations-demo.firebaseapp.com/loop-demo