在Angular 2中使用纯CSS动画可以通过以下步骤实现:
.animate {
animation: myAnimation 1s ease-in-out;
}
@keyframes myAnimation {
0% { opacity: 0; transform: translateX(-30px); }
100% { opacity: 1; transform: translateX(0); }
}
Hello, world!
export class MyComponent {
showElement: boolean = false;
toggleShow() {
this.showElement = !this.showElement;
}
}