NetanelBasal
1/10/2017 - 4:18 PM

control-errors.component.ts

@Component({
  selector: 'control-errors',
  template: '<p class="text-danger" *ngIf="error">{{error}}</p>'
})
export class ControlErrors  {
  
  @Input() control: string;
  @Input() errors: Object;
  form: FormGroup;
  error: string;
  
  constructor(@Optional() @Host() private form: NgForm) {
    if( !this.form ) {
      throw new Error('control-errors must be used with a parent formGroup directive');
    }
  }  
}