UNPKG

ipsos-components

Version:

Material Design components for Angular

19 lines (16 loc) 598 B
import {Component} from '@angular/core'; import {FormControl, Validators} from '@angular/forms'; /** @title Form field with error messages */ @Component({ selector: 'form-field-error-example', templateUrl: 'form-field-error-example.html', styleUrls: ['form-field-error-example.css'] }) export class FormFieldErrorExample { email = new FormControl('', [Validators.required, Validators.email]); getErrorMessage() { return this.email.hasError('required') ? 'You must enter a value' : this.email.hasError('email') ? 'Not a valid email' : ''; } }