我使用最新的離子框架,我看到角開發團隊添加了EmailValidator
功能。但我應該如何使用它有點不清楚。任何人都可以給我一個使用的例子嗎?ionic 3 EmailValidator用法
home.html的
<ion-content padding>
<ion-list>
<ion-item margin-vertical>
<ion-label>Enter email</ion-label>
<ion-input type="email" name="email" [(ngModel)]="email"></ion-input>
</ion-item>
</ion-list>
<button (type)="button" ion-button block large [disabled]="!email" (click)="checkValidation()">Check!</button>
</ion-content>
home.ts
import { Component } from '@angular/core';
import { IonicPage } from 'ionic-angular';
import { EmailValidator } from '@angular/forms';
@IonicPage()
@Component({
selector: 'page-login',
templateUrl: 'home.html'
})
export class LoginPage {
email: string;
constructor() {}
checkValidation() : string() {
// validation here
}
}