@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');
}
}
}