import { Component } from '@angular/core'; @Component({ selector: 'show-errors', template: `<div></div>`, }) export class ShowErrorsComponent { private static readonly errorMessages = { 'required': () => 'This field is required', 'minlength': (params) => 'The min number of characters is ' + params.requiredLength, 'maxlength': (params) => 'The max allowed number of characters is ' + params.requiredLength, 'pattern': (params) => 'The required pattern is: ' + params.requiredPattern, 'years': (params) => params.message }; private getMessage(type: string, params: any) { return ShowErrorsComponent.errorMessages[type](params); } }
0 nhận xét:
Post a Comment