Questions tagged [angular-formbuilder]

The FormBuilder provides syntactic sugar that shortens creating instances of a FormControl, FormGroup, or FormArray. It reduces the amount of boilerplate needed to build complex forms.

See the angular docs for more information

165 questions
28
votes
4 answers

Angular form builder vs form control and form group

Is there any advantage of using form control and form group over form builder? I have seen here that: The FormBuilder provides syntactic sugar that shortens creating instances of a FormControl, FormGroup, or FormArray. It reduces the amount of…
YulePale
  • 3,549
  • 6
  • 25
  • 59
15
votes
6 answers

Remove validators from form control Angular 6

I have a form with a lot of form controls and Validators for some of the controls, like: title = new FormControl("", Validators.compose([ Validators.required ])); description = new FormControl("", [ Validators.required, …
Mohammed
  • 377
  • 1
  • 4
  • 17
15
votes
7 answers

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

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…
8
votes
2 answers

How to user updateOn blur in FormBuilder

I have a custom async validator, and I want to set updateOn: 'blur' property using FormBuilder: myForm = this.formBuilder.group({ email: ['', [Validators.required], [this.myAsyncValidator]] // ... }); I tried this but it does not work: email:…
A-Sharabiani
  • 13,270
  • 12
  • 87
  • 109
8
votes
2 answers

control.setParent is not a function when dymanically creating formGroup

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…
matchifang
  • 3,889
  • 8
  • 36
  • 60
8
votes
3 answers

Angular : How to check if some control exist in form or not

Below is my code to get a response from the service. Here I am getting a list of employees. I need to bind form controls dynamically based on the response of service, my service returning more fields(EmployeeId, Name, Department etc.) than the form…
Sunil Kumar
  • 749
  • 2
  • 11
  • 23
7
votes
2 answers

Angular 7: "Cannot find control with unspecified name attribute"

I am creating my first Angular app and I am getting the following errors in dev mode console: ERROR Error: "Cannot find control with unspecified name attribute" ERROR Error: "Cannot find control with path: 'items -> name'" ERROR Error: "Cannot find…
5
votes
1 answer

How to validate error messages for nested form group fields in angular

Hi i am new for angular and i am trying to implement form validations and using below code and my problem is nested form group fields i am getting errors in log TypeError: Cannot read property 'touched' of null can some one help me please.. .ts …
Krish
  • 3,668
  • 10
  • 46
  • 86
4
votes
1 answer

Nested FormArray inside another FormArray

Heres what I'm trying to accomplish: In a page, a user will be able to upload their protections of certain Forex Pair. So, users can select different timeframes to upload their image analysis. My form is simple: dataForm: FormGroup; this.dataForm =…
4
votes
2 answers

Angular ReactiveForm to Model Mapping

I've been developing an app for a month now. I have come across many problems and almost all of them I've found solutions instead of opening threads but there is one design problem I still haven't figured out. Suppose I have a small component called…
4
votes
4 answers

Angular Reactive Form submit and clear validation

I have a reactive form
enter items
4
votes
1 answer

How to access formControlName in ngFor inside ngFor (nested formArray)?

I am a beginner of Angular 2. I am trying to create a table with dynamic form, table is created and value also bind but I am not able to access value in formControlName, tried below code but it did not work. could someone please help me where I am…
Vasanth
  • 390
  • 6
  • 14
3
votes
1 answer

Angular Reactive Forms controls vs Get

What is the difference between when i get the values in Reactive forms in below ways: this.someForm.controls['firstName'].value this.someForm.get('firstName').value public someForm: FormGroup = this.formBuilder.group({ firstName: ['',…
3
votes
0 answers

FormControl inside ngTemplate and ngContainer

I had a working angular form with repeating templates inside two conditions, so i have moved it out to a common place and defined ngContainer to display the value by passing the variables, however inside the template, the code is not able to figure…
Jithin P
  • 587
  • 2
  • 7
  • 25
3
votes
1 answer

How can I get the control name of a dynamic Angular field?

I am trying to push new controls dynamically into my formBuilder. /* templatesTypes = ["string1", "string2", "string3","string4"] */ /* templates = [{templateType: "string1", ...}, {templateType: "string2"}, ...]*/ this.agency = this.fb.group({ …
Kamoulox
  • 239
  • 2
  • 10
1
2 3
10 11