1
在Angular2应用程序,我试图做一个动画内的OnInit Angular2动画不起作用
这里是组件的HTML:
<div [@playBox]="state" id="toPlay" class="playBox rounded-box">
</div>
这里是动画:
animations:[
trigger('playBox',[
state('closed',style({
width: '5%',
backgroundColor:'red',
transform:'translateX(0)'
})),
state('wided',style({
width: '100%',
border: '3px solid red',
backgroundColor:'transparent'
})),transition('closed => wided',animate(4000))])
]
我当页面加载时,我将会激怒这个动画:
export class AppComponent implements OnInit{
state="closed";
public ngOnInit(): any
{
if(this.state=="closed"){
this.state="wided";
}
}