SHARE
TWEET

Untitled

a guest Apr 21st, 2017 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. protected showFormErrors(loginForm: NgForm): void {
  2.     const fields = Object.keys(this.formErrors);
  3.     for (let fieldKey in fields) {
  4.       if (!fields.hasOwnProperty(fieldKey)) {
  5.         continue;
  6.       }
  7.       let field = fields[fieldKey];
  8.       if (!loginForm.controls[field].valid) {
  9.         let errors = loginForm.controls.login.errors;
  10.         for (let key in errors) {
  11.           if (!errors.hasOwnProperty(key)) {
  12.             continue;
  13.           }
  14.           if (errors[key]) {
  15.             this[field + 'Error'] = this.formErrors[field][key];
  16.           }
  17.         }
  18.  
  19.         return;
  20.       }
  21.     }
  22.   }
RAW Paste Data
Top