I currently have a situation where I am rendering for every selected element within my multiselect angular material selectbox.
The rendering process functions correctly when I select an element, but the issue arises when I try to deselect one - it just keeps adding instead of removing.
My assumption is that I need to set a property like "deselect" or something similar, but I am not entirely sure. Could someone please assist me with this?
HTML:
<mat-select [formControl]="person" required>
<mat-option>--</mat-option>
<mat-option *ngFor="let person of person" [value]="person" (click)="getPerson()">
{{person.name}}
</mat-option>
</mat-select>
<div *ngFor="let person of personsArray">
<div class="card" >
<div class="card-body dl-card-body-no-padding-bottom" >
//element to render
</div>
</div>
TS:
getPerson(){
this.personsArray.push(this.form.controls.person.value)
}