我有一个角度6页,其中包含三个角度组件:
<component1 [@componentState]="componentToShow === 0 ? 'active' : 'inactive'"></component1>
<component2 [@componentState]="componentToShow === 1 ? 'active' : 'inactive'"></component2>
<component3 [@componentState]="componentToShow === 2 ? 'active' : 'inactive'"></component3>
animations: [
trigger('componentState', [
state('inactive', style({
backgroundColor: '#eee',
transform: 'scale(1)'
})),
state('active', style({
backgroundColor: '#cfd8dc',
transform: 'scale(1.1)'
})),
transition('inactive => active', animate('100ms ease-in')),
transition('active => inactive', animate('100ms ease-out'))
])
]
当我将componentToShow值更改为0、1或2时,我可以看到组件确实通过检查chrome开发工具中的元素获得了应用的比例和背景颜色,但是浏览器中的组件本身没有明显的变化。
我看到的所有示例都是将角度动画应用于标准HTML元素(div、buttons等),而没有将状态更改应用于角度组件的实例。
有人能告诉我我需要做什么让这个动画工作?