Hi, I’m trying to add a form by adding FormBuilder
and Validators
to an Ionic 2 tab template.
I believe that I’ve followed angular2/ionic2 form setup. But I’m getting a syntax error even though I’ve copied and pasted the code from examples.
Note: I’m not using TypeScript. I created the project by typing this on the Terminal $ ionic start cutePuppyPics --v2
This is the error that I get on the Terminal after typing ionic build ios
As you can see on the screenshot, the problem seems to be on the colon in fb: FormBuilder
in the constructor
This is my page3.js
import {Page} from 'ionic-angular';
import {FormBuilder, Validators} from 'angular2/common';
@Page({
templateUrl: 'build/pages/page3/page3.html'
})
export class Page3 {
constructor(fb: FormBuilder) {
// this.loginForm = fb.group({ // name should match [ngFormModel] in your html
// username: ["", Validators.required], // Setting fields as required
// password: ["", Validators.required]
// });
}
}
My page3.html
<ion-navbar *navbar>
<ion-title>
Tab 3
</ion-title>
</ion-navbar>
<ion-content class="page3">
<!-- <form [ngFormModel]="loginForm" (submit)="login($event)">
<ion-input stacked-label>
<ion-label>Username</ion-label>
<input type="text" ngControl="username">
</ion-input>
<ion-input stacked-label>
<ion-label>Password</ion-label>
<input type="password" ngControl="password">
</ion-input>
<div padding>
<button block type="submit" [disabled]="!loginForm.valid">Login</button>
</div>
</form> -->
</ion-content>
I’ve commented some blocks of code in my html
and my js
bec. I was debugging.
What is exactly wrong?