angular-formbuilder

Angular 5: Dynamic Form Validation inside a table

十年热恋 提交于 2019-12-11 02:58:30
问题 I am trying to validate input fields inside a table using form group but unable to achieve the same. I am using *ngFor to iterate the data because I have to display that data in the first column of the table and other columns are just input text fields in which I have to add form validation. So I have added the index for the unique form control name for the field. HTML code <form [formGroup]="tableForm"> <table class="shop-table table-responsive" cellspacing="0"> <tbody> <tr class="cart_item"

control.setParent is not a function when dymanically creating formGroup

独自空忆成欢 提交于 2019-12-10 15:48:24
问题 I'm using Angular5, and I have a list of fields, each has a name and FormControl. I try to dynamically add the controls to the group, using this code, but I got an error. const formControlFields = [ {name: 'field1',control: [null, []] as FormControl}, {name: 'field2',control: [null, []] as FormControl} ]; const formGroup: FormGroup = new FormGroup({}); formControlFields.forEach( f => formGroup.addControl(f.name,f.control)); this.form = new FormGroup({groups:formGroup}); This is the error I

Angular 6: Can't bind to 'formGroup' since it isn't a known property of 'form'?

本小妞迷上赌 提交于 2019-12-10 12:34:58
问题 I have worked with form builder in angular 2/4, But now I am using it in angular 6. I have seen this question (Can't bind to 'formGroup' since it isn't a known property of 'form') but it was for angular 2. I doing exact same against angular 4 but I am getting this error. Please help: my code are: app.module.ts: ( I have exported FormsModule & ReactiveFormsModule) : import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { LocalStorage } from