Closed mkndn closed 7 years ago
I have the following html script
<form [formGroup]="testForm" novalidate (ngSubmit)="save(testForm.value)"> <div fomArrayName="testAttributes"> <div [formGroupName]="0"> <sm-select [options]="{direction: 'downward'}" placeholder="Attributes" [formControl]="attributeMaster" (onChange)="updateModel($event);" class="fluid"> <option *ngFor="let item of selectAttributes" [value]="item.label"> <span [innerHTML]="item.value.displayName"></span> </sm-select> </div> </div> </form>
And in my component
public buildForm(): void { this.testForm = this._fb.group({ testAttributes: this._fb.array([]) }); this.loadFormArray(); } public loadFormArray(): void { this.attributesFromServer.forEach(attribute => { (<FormArray>this.testForm.controls["testAttributes"]).push(this.createArrayData(attribute)) }) } public createArrayData(attribute: Attribute) { return this._fb.group({ attributeMaster: [attribute.attributeMaster, <any>Validators.required] }) }
When i run the application, i am getting the following error,
Cannot find control with unspecified name attribute
When i change the html script to
<sm-select [options]="{direction: 'downward'}" placeholder="Attributes" formControlName="attributeMaster" (onChange)="updateModel($event);" class="fluid"> <option *ngFor="let item of selectAttributes" [value]="item.label"> <span [innerHTML]="item.value.displayName"></span> </sm-select>
Iam getting the following error,
No value accessor for form control with path: 'testAttributes -> 0 -> attributeMaster
And the error point to the line where we set the formControl attribute for sm-select above. Please help.
I got it working. My bad i didn't notice the [control] attribute for sm-select in the demo page before. My Apologies. I changed [formControl] to [control] and it's working now.
I have the following html script
And in my component
When i run the application, i am getting the following error,
When i change the html script to
Iam getting the following error,
And the error point to the line where we set the formControl attribute for sm-select above. Please help.