Angular после щелчка Добавить активный класс и удалить с братьев и сестер
import { Output, EventEmitter } from '@angular/core';
@Output() itemSelectEvent= new EventEmitter<string>();
select(array_item){
itemSelectEvent.emit(array_item.id);
}
<app-item-desc *ngFor="let itemDesc of addedItem; let i = index" [itemlistDesc]="itemDesc" (itemSelectEvent)="selectEventHandler($event)"></app-item-desc>
selectEventHandler(event){
// event, you will get selected id here
for(let i=0;i < addedItem.length;i++){
if(addedItem[i].id == event){
addedItem[i]['is_active'] = true;
}else{
addedItem[i]['is_active'] = false;
}
}
}
<div class="order" (click)="select($event)" [ngClass]="{'active': itemlistDesc.is_active}">
</div>
SAMER SAEID