@@ -7,6 +7,7 @@ import { BooleanInput, coerceBooleanProperty } from '@angular/cdk/coercion';
7
7
} )
8
8
export class FormCheckInputDirective {
9
9
10
+ static ngAcceptInputType_checked : BooleanInput ;
10
11
static ngAcceptInputType_indeterminate : BooleanInput ;
11
12
12
13
/**
@@ -23,15 +24,21 @@ export class FormCheckInputDirective {
23
24
*/
24
25
@Input ( )
25
26
set indeterminate ( value : boolean ) {
26
- const newValue = coerceBooleanProperty ( value ) ;
27
- if ( this . _indeterminate !== newValue ) {
28
- this . _indeterminate = newValue ;
29
- this . renderer . setProperty ( this . hostElement . nativeElement , 'indeterminate' , newValue ) ;
27
+ const indeterminate = coerceBooleanProperty ( value ) ;
28
+ if ( this . _indeterminate !== indeterminate ) {
29
+ this . _indeterminate = indeterminate ;
30
+ const htmlInputElement = this . hostElement . nativeElement as HTMLInputElement ;
31
+ if ( indeterminate ) {
32
+ this . renderer . setProperty ( htmlInputElement , 'checked' , false ) ;
33
+ }
34
+ this . renderer . setProperty ( htmlInputElement , 'indeterminate' , indeterminate ) ;
30
35
}
31
36
} ;
37
+
32
38
get indeterminate ( ) {
33
39
return this . _indeterminate ;
34
40
}
41
+
35
42
private _indeterminate = false ;
36
43
37
44
/**
@@ -49,6 +56,15 @@ export class FormCheckInputDirective {
49
56
} ;
50
57
}
51
58
59
+ @Input ( )
60
+ set checked ( value : boolean ) {
61
+ const checked = coerceBooleanProperty ( value ) ;
62
+ const htmlInputElement = this . hostElement ?. nativeElement as HTMLInputElement ;
63
+ if ( htmlInputElement ) {
64
+ this . renderer . setProperty ( htmlInputElement , 'checked' , checked ) ;
65
+ }
66
+ }
67
+
52
68
get checked ( ) : boolean {
53
69
return this . hostElement ?. nativeElement ?. checked ;
54
70
}
0 commit comments