How do I bind the Google Angular Materials matselection-list with the FormBuilder? We have following class, and trying to use Reactive formBuilder. We know how to bind to the data class with NgModel, but want to bind to the actual formbuilder. What is the process to conduct this with mat-selection-list?
class product{
productId: number;
productCode: string;
productDescription
private formBuilder: FormBuilder, ) {
products: this.fb.array([])
}
Also need validation requirements below,
'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 is a multiple select form.
Was trying to research this, Binding an Angular Material Selection List