I have component that wraps input field. In the component i receive the Control
object from @Input() inputControl: Control;
. In the template i have
I couldn't get the above to work which isn't surprising given the changes to Angular since Jan. With the latest version of Angular (2.2.0)you will need something like this in your class.
get required(): boolean {
var _validator: any = this.inputControl.validator && this.inputControl.validator(this.inputControl);
return _validator && _validator.required;
}
This will also handle the case where you have multiple validators in a reactive form e.g.
name: ['', [Validators.required, Validators.minLength(2)]]