【发布时间】:2021-09-08 18:47:06
【问题描述】:
我有以下动画
animations: [
trigger('someAnimation', [
state('inactive', style({ opacity: 0 })),
state('active', style({ opacity: 1 })),
state('removed', style({ opacity: 0 })),
transition(
'inactive => active',
animate('{{ variable }}')
),
transition(
'active => removed',
animate('{{ secondVariable ? secondVariable : variable }}') // not working, just an example
)
])
],
还有这个主机绑定:
@HostBinding('@someAnimation')
state = {
value: 'inactive',
params: {
variable: this.getVariable(),
secondVariable: this.getSecondVariable()
}
};
因此,如果第二个变量未定义或没有我想要的值,我会尝试退回第一个变量。
你知道我怎样才能实现这样的目标吗? animate('{{ secondVariable ? secondVariable : 变量 }}')
PS:这是我第一次在 Angular 中使用动画,我已经阅读了几篇文章并检查了文档,但还没有找到类似的东西。
提前致谢!
【问题讨论】:
标签: angular angular-animations