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

213 questions
59
votes
5 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
  • 6,688
  • 16
  • 46
  • 95
20
votes
7 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, …
17
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…
15
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
  • 17,750
  • 17
  • 113
  • 128
15
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
  • 909
  • 2
  • 17
  • 31
12
votes
3 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
  • 5,190
  • 12
  • 47
  • 76
8
votes
2 answers

What is the angular registerControl() method for

I saw that angular form had the following method registerControl(), but I couldn't really understand its usage. Does somebody have a nice explanation and a use case for it? I have the feeling I'm missing something that could be useful. Thx for your…
Raphaël Balet
  • 6,334
  • 6
  • 41
  • 78
7
votes
1 answer

angular (form array) value changes is not working

Form array value changes is not working. I can't console the value inside subscriber method. Here is my basic form array code below. ordersData = [ { id: 100, name: 'order 1' }, { id: 200, name: 'order 2' }, { id: 300, name: 'order 3'…
7
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: ['',…
Ankit singh
  • 71
  • 1
  • 3
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…
7
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
  • 4,166
  • 11
  • 58
  • 110
7
votes
4 answers

Angular Reactive Form submit and clear validation

I have a reactive form
enter items
5
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…
BLACKMAMBA
  • 675
  • 2
  • 11
  • 28
4
votes
2 answers

Angular Subscribe valuechanges in formarray in form group

I'm angular8 and I have a form array inside of form group but I want to detect new changes of a certain input. ngOnInit(): void { this.makeForm = this.fb.group({ year:['', Validators.required], amount:['',…
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 =…
1
2 3
14 15