formarray

display form array on selection of dropdwon in angular

时光总嘲笑我的痴心妄想 提交于 2021-02-11 06:52:12
问题 I have a form with following fields: name (textbox), category(dropdown). I want to display a formarray textbox with an add option on selection of dropdwon="3". When i click "add new textfields", new textboxes should be added. Right now i'm showing a textbox (listitem) after selection of dropdown="3". and then on addnewtextfield i'm calling a formarray. Please help me acheive the functionality. Thanks in advance. Updated code in Stackblitz: https://stackblitz.com/edit/angular-ivy-js8tfp?file

display form array on selection of dropdwon in angular

空扰寡人 提交于 2021-02-11 06:52:02
问题 I have a form with following fields: name (textbox), category(dropdown). I want to display a formarray textbox with an add option on selection of dropdwon="3". When i click "add new textfields", new textboxes should be added. Right now i'm showing a textbox (listitem) after selection of dropdown="3". and then on addnewtextfield i'm calling a formarray. Please help me acheive the functionality. Thanks in advance. Updated code in Stackblitz: https://stackblitz.com/edit/angular-ivy-js8tfp?file

Angular Reactive Forms in Reusable Child Components: Problem with FormArrays: `formGroupName` must be used with a parent formGroup directive

馋奶兔 提交于 2021-02-06 14:01:02
问题 I'am trying to describe the problem on an example (full example on stackblitz) If I try to place some parts of reactive-form in the form of simple "formControls" or "formGroups" withing child-components, there are no problems. (See the example on stackblitz above). FormGroupDirective works as expected. But If I try to place a FormArray within a child-component, I get troubles because of: <div [formGroupName]="i"> <!-- Error: formGroupName must be used with a parent formGroup directive. -->

Angular Reactive Forms in Reusable Child Components: Problem with FormArrays: `formGroupName` must be used with a parent formGroup directive

核能气质少年 提交于 2021-02-06 13:50:52
问题 I'am trying to describe the problem on an example (full example on stackblitz) If I try to place some parts of reactive-form in the form of simple "formControls" or "formGroups" withing child-components, there are no problems. (See the example on stackblitz above). FormGroupDirective works as expected. But If I try to place a FormArray within a child-component, I get troubles because of: <div [formGroupName]="i"> <!-- Error: formGroupName must be used with a parent formGroup directive. -->

Dynamic form array with dynamic options

笑着哭i 提交于 2021-02-05 09:29:39
问题 I want to make a student able to choose several workshops in a dynamic number of school subjects 1.- I have a config array, this array have the number of options of the student will choose for every subject let configarray = {initdate: 2019-07-01, subjectnumber: 4}; In this example for every subject the student will be able to choose 4 options. let b = this.FormGuardar.get("opciontaller") as FormArray; for (let i = 0; i < configarray.subjectnumber; i++) { let preregistro = this._fb.group({

How can we set errors on form array control dynamically on initally page load

北城余情 提交于 2021-01-29 10:33:46
问题 In one of my requirements, I have form an array-like grid table contains rows and columns. once on Init i am doing a service call and get the columns and values and error messages. based on that i have created a form array for that columns and each columns have errormessage if errormessage exists need to set errors. I can able to set value for those columns but not able to set errors while pushing into form array i don't know how could I push error as well. stuck on this line. Qn? On

Angular 7 and form arrays error of cannot find a control with path

时间秒杀一切 提交于 2021-01-28 11:25:32
问题 I am building a form group with an array inside of it, using mat-table data source. I started by creating the table: <form *ngIf="formGroup" [formGroup]="formGroup"> <table mat-table [dataSource]="dataSource" *ngIf="total>0" formArrayName="distribution"> <ng-container matColumnDef="ind_id"> <th mat-header-cell *matHeaderCellDef> ID </th> <td mat-cell *matCellDef="let element">{{element.individual_id}}</td> </ng-container> <ng-container matColumnDef="ind_name"> <th mat-header-cell

Angular2 patchValue JSON data to formArray

孤街醉人 提交于 2020-12-29 12:11:20
问题 I have a Json data like this: assets/details.json { "name" : "john", "age" : 20, "address" : [{ "main": "address1", "sub": "address2" }, { "main": "add1", "sub": "add2" }] } I want to show those all JSON data in Angular forms with patchValue . I've tried this. app.component.ts export class AppComponent { data: FormGroup constructor(private FB: FormBuilder, private service: DataService) { } ngOnInit() { this.data = this.FB.group({ name: [''], age: [''], address: this.FB.array([ this.addAddress

Angular2 patchValue JSON data to formArray

笑着哭i 提交于 2020-12-29 12:01:10
问题 I have a Json data like this: assets/details.json { "name" : "john", "age" : 20, "address" : [{ "main": "address1", "sub": "address2" }, { "main": "add1", "sub": "add2" }] } I want to show those all JSON data in Angular forms with patchValue . I've tried this. app.component.ts export class AppComponent { data: FormGroup constructor(private FB: FormBuilder, private service: DataService) { } ngOnInit() { this.data = this.FB.group({ name: [''], age: [''], address: this.FB.array([ this.addAddress

Angular2 patchValue JSON data to formArray

我是研究僧i 提交于 2020-12-29 12:00:15
问题 I have a Json data like this: assets/details.json { "name" : "john", "age" : 20, "address" : [{ "main": "address1", "sub": "address2" }, { "main": "add1", "sub": "add2" }] } I want to show those all JSON data in Angular forms with patchValue . I've tried this. app.component.ts export class AppComponent { data: FormGroup constructor(private FB: FormBuilder, private service: DataService) { } ngOnInit() { this.data = this.FB.group({ name: [''], age: [''], address: this.FB.array([ this.addAddress