I have two list of items, and I want to animate each of them when the fa caret which belongs to it parent is clicked.
here is html:
<li>
<div>
<span> something1</span>
<i class="fa fa-angle-right" (click)="toggleList()"></i>
</div>
<ul [@elementState]="showlist">
<li>something2</li>
<li>something3</li>
</ul>
</li>
<li>
<div>
<span>something4</span>
<i class="fa fa-angle-right" (click)="toggleList()"></i>
</div>
<ul [@elementState]="showlist">
<li >something5</li>
<li >something6</li>
</ul>
</li>
here is ts from @component:
animations: [
trigger('elementState', [
state('show', style({
'height':'88px'
})),
state('hide', style({
'hide':'0px'
})),
transition('show <=> hide', animate('300ms'))
])
]
and here is some ts from class:
showlist = 'hide';
toggleList(){
this.showlist = this.showlist === 'hide' ? 'show' : 'hide';
}
And I am aiming to make those two list open separetly, because for the moment each icon click triggers animation for both list and that is not what I would like to happen.
I thought of making individual animation for each but there would be a lot code repetition so if thats possible I want to avoid that.
Does anyone know the trick to make it work ?
showlist. The behavior you are seeing is to be expected.