fix(forms): avoid issues with nulls checking on validation status and other form states.
Closes #4338
This commit is contained in:
@ -1,19 +1,22 @@
|
||||
import {AbstractControl} from '../model';
|
||||
import {isPresent} from 'angular2/src/core/facade/lang';
|
||||
|
||||
export class AbstractControlDirective {
|
||||
get control(): AbstractControl { return null; }
|
||||
|
||||
get value(): any { return this.control.value; }
|
||||
get value(): any { return isPresent(this.control) ? this.control.value : null; }
|
||||
|
||||
get valid(): boolean { return this.control.valid; }
|
||||
get valid(): boolean { return isPresent(this.control) ? this.control.valid : null; }
|
||||
|
||||
get errors(): StringMap<string, any> { return this.control.errors; }
|
||||
get errors(): StringMap<string, any> {
|
||||
return isPresent(this.control) ? this.control.errors : null;
|
||||
}
|
||||
|
||||
get pristine(): boolean { return this.control.pristine; }
|
||||
get pristine(): boolean { return isPresent(this.control) ? this.control.pristine : null; }
|
||||
|
||||
get dirty(): boolean { return this.control.dirty; }
|
||||
get dirty(): boolean { return isPresent(this.control) ? this.control.dirty : null; }
|
||||
|
||||
get touched(): boolean { return this.control.touched; }
|
||||
get touched(): boolean { return isPresent(this.control) ? this.control.touched : null; }
|
||||
|
||||
get untouched(): boolean { return this.control.untouched; }
|
||||
get untouched(): boolean { return isPresent(this.control) ? this.control.untouched : null; }
|
||||
}
|
Reference in New Issue
Block a user