Could you please guide me on how to connect the Google Angular Materials mat-selection-list with the FormBuilder? We have the following class and are attempting to utilize Reactive Form Builder for this purpose. While we are aware of how to link data classes with NgModel, we are seeking information on binding them to the actual form builder itself. What steps should be taken in order to achieve this with mat-selection-list?
class product{
productId: number;
productCode: string;
productDescription
private formBuilder: FormBuilder, ) {
products: this.fb.array([])
}
In addition, what validation criteria are necessary as follows:
'product': this.formBuilder.group({
'productId': [null, [Validators.required]],
'productCode': [null, [Validators.required, Validators.maxLength(50)]],
'productDescription': [null, [Validators.required, Validators.maxLength(255)]]
})
<mat-selection-list #productList class = "selectionlist" [(ngModel)]="selectedOptions" (selectionChange)="productChangeEvent($event,productList?.selectedOptions.selected)">
<mat-list-option *ngFor="let product of products">
{{product.productDescription}}
</mat-list-option>
</mat-selection-list>
This pertains to a multiple selection form.
I have been searching for more information on this topic, Binding an Angular Material Selection List