/
githubmirror
/
components
Обзор
Документация
Войти
/
githubmirror
/
components
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/components-examples/material/input/input-error-state-matcher/input-error-state-matcher-example.ts
33 строки
1 KB
Kristiyan Kostadinov
docs: remove standalone flag from examples
17 окт 2024, 17:40
17 окт 2024, 17:40
36f4cca
Код
Авторство
О чём код?
import {Component} from '@angular/core'; import { FormControl, FormGroupDirective, NgForm, Validators, FormsModule, ReactiveFormsModule, } from '@angular/forms'; import {ErrorStateMatcher} from '@angular/material/core'; import {MatInputModule} from '@angular/material/input'; import {MatFormFieldModule} from '@angular/material/form-field'; /** Error when invalid control is dirty, touched, or submitted. */ export class MyErrorStateMatcher implements ErrorStateMatcher { isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean { const isSubmitted = form && form.submitted; return !!(control && control.invalid && (control.dirty || control.touched || isSubmitted)); } } /** @title Input with a custom ErrorStateMatcher */ @Component({ selector: 'input-error-state-matcher-example', templateUrl: './input-error-state-matcher-example.html', styleUrl: './input-error-state-matcher-example.css', imports: [FormsModule, MatFormFieldModule, MatInputModule, ReactiveFormsModule], }) export class InputErrorStateMatcherExample { emailFormControl = new FormControl('', [Validators.required, Validators.email]); matcher = new MyErrorStateMatcher(); }