我试图在角度为不同的元素使用相同的动画,这些元素应该单击
<div id="a" #a [@blast]="state" (click)="yell($event)"><div>
<div id="b" #b [@blast]="state" (click)="yell($event)"><div>
<div id="c" #c [@blast]="state" (click)="yell($event)"><div>
yell(event){
let idAttr=event.srcElement.attributes.id
var value = idAttr.nodeValue; //to get divs id
if(value==="a"){
//for element "a" only, animate with blast animation
}
if(value==="b"){
//for element "b" only, animate with blast animation
}
if(value==="b"){
//for element "b" only, animate with blast animation
}
}
最聪明的选择是什么?
答案 0 :(得分:0)
嗯,我认为这可能是最好的选择:
<div id="a" #a [@blast]="a_status" (click)="yell($event)"><div>
<div id="b" #b [@blast]="b_status" (click)="yell($event)"><div>
<div id="c" #c [@blast]="c_status" (click)="yell($event)"><div>
a_status:string;
b_status:string;
c_status:string;
yell(event){
let idAttr=event.srcElement.attributes.id
var value = idAttr.nodeValue; //to get divs id
if(value==="a"){
this.a_status="fire"
}
if(value==="b"){
this.b_status="fire"
}
if(value==="b"){
this.c_status="fire"
}
}