FormBuilder error "this.form._updateTreeValidity is not a function"


#1

I’m attempting to follow the Ionic 2 and Forms instructions and get the error:

this.form._updateTreeValidity is not a function

which my app is not calling directly, and in fact don’t see my app in the stack at all.

login.ts:

 ionViewLoaded() {
    this.loginForm = this.formBuilder.group({
      email: ['', Validators.required],
      password: ['', Validators.required],
    });
  }

  login() {
    console.log("Get rosters");
  }

And login.html:

<form [formGroup]="loginForm" (ngSubmit)="login()">
	<ion-item>
		<ion-label>Email address</ion-label>
		<ion-input type="email" formControlName="email"></ion-input>
	</ion-item>
	<ion-item>
		<ion-label>Password</ion-label>
		<ion-input type="password" formControlName="password"></ion-input>
	</ion-item>
	<button ion-button type="submit" [disabled]="!loginForm.valid">Submit</button>
</form>

#2

This error disappeared at some point was replaced with a problem that the formGroup wasn’t set. I eventually discovered that with a Modal, it’s necessary to create the formGroup in the constructor, not in ionViewDidLoad.