This repository was archived by the owner on Oct 7, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ import { MdcRipple } from '../ripple/ripple.directive';
21
21
import { MDCCheckboxAdapter } from './checkbox-adapter' ;
22
22
import { MDCCheckboxFoundation } from '@material/checkbox' ;
23
23
24
- let nextElId_ = 0 ;
24
+ let nextUniqueId = 0 ;
25
25
26
26
export const MD_CHECKBOX_CONTROL_VALUE_ACCESSOR : Provider = {
27
27
provide : NG_VALUE_ACCESSOR ,
@@ -31,6 +31,9 @@ export const MD_CHECKBOX_CONTROL_VALUE_ACCESSOR: Provider = {
31
31
32
32
@Component ( {
33
33
selector : 'mdc-checkbox' ,
34
+ host : {
35
+ '[id]' : 'id' ,
36
+ } ,
34
37
template :
35
38
`
36
39
<input type="checkbox"
@@ -65,11 +68,11 @@ export const MD_CHECKBOX_CONTROL_VALUE_ACCESSOR: Provider = {
65
68
} )
66
69
67
70
export class MdcCheckboxComponent implements AfterViewInit , OnDestroy {
68
- @ Input ( ) id : string = `mdc-checkbox-${ ++ nextElId_ } ` ;
69
- @ Input ( ) name : string ;
70
- get inputId ( ) : string {
71
- return `input- ${ this . id } ` ;
72
- }
71
+ private _uniqueId : string = `mdc-checkbox-${ ++ nextUniqueId } ` ;
72
+
73
+ @ Input ( ) id : string = this . _uniqueId ;
74
+ get inputId ( ) : string { return `${ this . id || this . _uniqueId } -input` ; }
75
+ @ Input ( ) name : string | null = null ;
73
76
@Input ( )
74
77
get checked ( ) { return this . _foundation . isChecked ( ) ; }
75
78
set checked ( value ) {
You can’t perform that action at this time.
0 commit comments