@wouterh wrote:
Hi people, I have a Formbuilder and a template. Now I want to access the type group. But can’t access it in my template. Get the error:
Cannot not find control wtith path websites- -> 0.
Can someone help me out? This is the code:Angular typescript
createForm() { this.websiteForm = this.formBuilder.group({ websites: this.formBuilder.array([ this.initWebsite() ]) }); } initWebsite() { return this.formBuilder.group({ url: ['', Validators.required], type: this.formBuilder.group({ id: ['', Validators.required] }),
Template Angular
<form [formGroup]="websiteForm" novalidate> <div formArrayName="websites"> <div *ngFor="let website of websiteForm.controls.websites.controls; let i=index" [formGroupName]="i" > <ion-item> <ion-label floating>URL</ion-label> <ion-input type="text" name="url" formControlName="url" > </ion-input> </ion-item> <div [formGroupName]="type"> <ion-item> <ion-label>Type</ion-label> <ion-select interface="popover" formControlName="id"> <ion-option *ngFor="let item of types" [value]="item.id">{{ item.name }}</ion-option> </ion-select> </ion-item> </div> </div> </div> </form>```
Posts: 1
Participants: 1