How can I properly bind ngFormModal
in my Ionic 2 project? I am facing an issue while trying to import it on my page, resulting in the following error message:
Uncaught (in promise): Template parse errors:
Can't bind to 'ngFormModel' since it isn't a known native property ("
Could someone guide me on how to correctly bind ngFormModal
in Ionic 2 beta.37 version? I have ensured that all necessary dependencies are imported (refer to my comments for more details). Even after updating my Ionic version, the problem still persists.
HTML:
<form [ngFormModel]="registrationForm">
<ion-list class="lis1">
<ion-row>
<ion-item width-50 >
<ion-label floating >First Name</ion-label>
<ion-input type="text" [(ngModel)]="firstName" ngControl="first" ></ion-input>
</ion-item>
<ion-item width-50 >
<ion-label floating>Last Name</ion-label>
<ion-input type="text" [(ngModel)]="lastName" ngControl="last" ></ion-input>
</ion-item>
</ion-row>
<ion-item>
<ion-label floating>Email</ion-label>
<ion-input type="email" [(ngModel)]="email" ngControl="email" ></ion-input>
</ion-item>
</ion-list>
</form>
<ion-footer>
<ion-toolbar>
<button primary full (click)="register()" >Register</button>
<p>{{regMsg}}</p>
</ion-toolbar>
</ion-footer>
TypeScript:
import {FormBuilder, ControlGroup, Validators, NgFormModel} from '@angular/common';
public registrationForm: any;
constructor(private navCtrl: NavController, private persistence: AutoSparesPersistence,
private rest: Rest, private logger: Logger, private user:Users,public _form: FormBuilder) {
this.registrationForm = this._form.group({
"email":["",Validators.compose([Validators.required, Validators.pattern('[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$')])],
"date":["",Validators.required],
"first":["",Validators.compose([Validators.maxLength(64),Validators.required])],
"last":["",Validators.compose([Validators.maxLength(64),Validators.required])],
"payment":["",Validators.required],
"phone":["",Validators.compose([Validators.maxLength(10),Validators.minLength(10) , Validators.required])],
"categ":["",Validators.required],
"company":["",Validators.compose([Validators.maxLength(64),Validators.required])],
"tgNo":["",Validators.required],
"num1":["",Validators.compose([Validators.maxLength(10),Validators.required])],
"fax":["",Validators.compose([Validators.maxLength(12),Validators.minLength(12),Validators.required])],
"addr":["",Validators.compose([Validators.maxLength(64),Validators.required])],
"trc":["",Validators.compose([Validators.maxLength(64),Validators.required])],
"state":["",Validators.required],
"country":["",Validators.required],
"pin":["",Validators.compose([Validators.maxLength(6),Validators.minLength(6),Validators.required])]
})
}