TypeError: this.form._updateTreeValidity is not a function

Binding the template variable #contactForm appears to cause a name conflict and blow up the template processor as it tries to turn the attached template variable into an NgForm on the backend. Everywhere I have seen model driven forms used there is no template variable binding on the form, whereas there is a #tv=”ngForm” utilized … Read more

How to add form validation pattern in Angular 2?

Now, you don’t need to use FormBuilder and all this complicated valiation angular stuff. I put more details from this (Angular 2.0.8 – 3march2016): https://github.com/angular/angular/commit/38cb526 Example from repo : <input [ngControl]=”fullName” pattern=”[a-zA-Z ]*”> I test it and it works 🙂 – here is my code: <form (ngSubmit)=”onSubmit(room)” #roomForm=’ngForm’ > … <input id=’room-capacity’ type=”text” class=”form-control” [(ngModel)]=’room.capacity’ … Read more

Angular2 – How to set `touched` property on form to true

There’s a pretty straightforward method to do this: markAsTouched. It should be enough to use it on the form group. this.addressForm.markAsTouched() In case you want for some reason to mark all controls manually, they itself have this method available. markAsTouched is a method of the AbstractControl all form elements inherit from. Out of curiosity, you … Read more

Angular 2 Form “Cannot find control with path”

There should be a formControlName in your HTML form mapped to your component file. <div *ngFor=”let list_item of [0,1,2]; let i=index” class=”panel panel-default”> {{i + 1}}.) <input type=”text” formControlName=”{{i}}” placeholder=”List Item” class=”form-control”> </div> list_items: this.fb.array([ [”], //0 points to this [”], //1 points to this [”] //2 points to this ])

How can I pass the FormGroup of a parent component to its child component using the current Form API

In the parent component do this: <div [formGroup]=”form”> <div>Your parent controls here</div> <your-child-component [formGroup]=”form”></your-child-component> </div> And then in your child component you can get hold of that reference like so: export class YourChildComponent implements OnInit { public form: FormGroup; // Let Angular inject the control container constructor(private controlContainer: ControlContainer) { } ngOnInit() { // Set … Read more