Angular 角度动画。事件后更新动画状态
假设我的组件html中有以下内容Angular 角度动画。事件后更新动画状态,angular,angular-animations,Angular,Angular Animations,假设我的组件html中有以下内容 <div *ngFor='let box of boxes' [@fade_out]='off'> <h1> Author: {{ box.author }} </h1> <button (click)='delete(box)'>Delete box</button> </div> 我希望能够动态更新用户在收到对话框响应后单击的特定div的[@fade_out]状态 如果我将[@fa
<div *ngFor='let box of boxes' [@fade_out]='off'>
<h1> Author: {{ box.author }} </h1>
<button (click)='delete(box)'>Delete box</button>
</div>
我希望能够动态更新用户在收到对话框响应后单击的特定div的[@fade_out]状态
如果我将[@fade_out]绑定到控制器中的一个布尔值,则所有其他框都将触发相同的动画,因此所有框都将淡出
如果我将[@fade_out]绑定到一个函数,我就不知道在得到响应后如何为该特定div触发该特定函数
有人能给我建议一种方法让这项工作成功吗?所以答案就在那里,我没有看到。根据文档,我只是将动画链接到对象的属性
<div *ngFor='let box of boxes' [@fade_out]='box.state'>
<h1> Author: {{ box.author }} </h1>
<button (click)='delete(box)'>Delete box</button>
</div>
<div *ngFor='let box of boxes' [@fade_out]='box.state'>
<h1> Author: {{ box.author }} </h1>
<button (click)='delete(box)'>Delete box</button>
</div>
dialog.open(...).afterClosed().subscribe( response => {
box.state = response
}