I am using the material checkbox and material select

the select options are dynamic it's based on previous form fields in the same fromarray


check the link, please understand the other conditions and check the console

the Field_Filter function is called multiple times in a single checkbox click.

anyone suggest me how to solve this issue or provide an alternate solution

1 Answers

david McDougald On

It looks like since you passed the function Field_Filter() as a paramater for the *ngFor loop, the function is being called on each iteration.

Instead, have the function write to a variable, and use *ngFor to iterate over that variable.


HTML: <mat-option *ngFor="let Fields of FilteredList" [value]="Fields._id"> {{Fields.Name}} </mat-option>


filteredList: [any]

someEventFunction(Type: any, Index: any) {

this.filteredList = Field_Filter(Type, Index)


I had a little trouble determining what your desired behavior is, so I wasn't able to get you a complete working example, but I hope this helps!