我在 repo 协议(protocol)上有一个悬而未决的问题 here ,但我认为无论如何在这里提问都会很有用。
我想以编程方式从指令中触发动画。使用 Renderer.animate
时,我得到:
Renderer.animate is no longer supported!
当使用 Renderer.invokeElementMethod
时,我得到:
Cannot read property 'apply' of undefined
我该怎么做?
最佳答案
Angular 即将发生变化!参见 this GitHub issue在官方的 Angular 仓库中。
长话短说
What's really good: With the first beta of angular 4.1 (which comes out as the follow-up release to this weeks 4.0.0) you can do the following:
class MyCmp {
constructor(private _builder: AnimationBuilder) {
}
myMethod() {
const animation = this._builder.build([
style(...),
animate(...),
group([
animate(...)
animate(...)
animate(...)
])
]);
const player = animation.create(someElement);
player.play();
}
}
关于javascript - Angular 4 - 如何从指令中运行动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42898505/