File tree Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -45,3 +45,20 @@ <h1>md-checkbox: Basic Example</h1>
45
45
46
46
< h1 > Nested Checklist</ h1 >
47
47
< md-checkbox-demo-nested-checklist > </ md-checkbox-demo-nested-checklist >
48
+
49
+ < md-card >
50
+ < md-checkbox [(ngModel)] ="checked " [indeterminate] ="indeterminate ">
51
+ Active
52
+ </ md-checkbox >
53
+ < br >
54
+ < label >
55
+ < input type ="checkbox " [(ngModel)] ="checked " [(indeterminate)] ="indeterminate ">
56
+ Active
57
+ </ label >
58
+ < br > < br > < br >
59
+ < button (click) ="checked=!checked "> Toggle Checked: {{checked}}</ button >
60
+
61
+ < button (click) ="indeterminate=!indeterminate "> Toggle Indeterminate: {{indeterminate}}</ button > < br >
62
+
63
+
64
+ </ md-card >
Original file line number Diff line number Diff line change @@ -63,6 +63,9 @@ export class MdCheckboxDemoNestedChecklist {
63
63
styleUrls : [ 'checkbox-demo.css' ] ,
64
64
} )
65
65
export class CheckboxDemo {
66
+ checked : boolean = true ;
67
+ indeterminate : boolean = true ;
68
+
66
69
isIndeterminate : boolean = false ;
67
70
isChecked : boolean = false ;
68
71
isDisabled : boolean = false ;
Original file line number Diff line number Diff line change @@ -160,7 +160,7 @@ export class MdCheckbox implements ControlValueAccessor {
160
160
}
161
161
162
162
/**
163
- * Whether the checkbox is checked. Note that setting `checked` will immediately set
163
+ * Whether the checkbox is checked. Note that setting `checked` to true will immediately set
164
164
* `indeterminate` to false.
165
165
*/
166
166
@Input ( ) get checked ( ) {
@@ -169,7 +169,9 @@ export class MdCheckbox implements ControlValueAccessor {
169
169
170
170
set checked ( checked : boolean ) {
171
171
if ( checked != this . checked ) {
172
- this . _indeterminate = false ;
172
+ if ( checked ) {
173
+ this . indeterminate = false ;
174
+ }
173
175
this . _checked = checked ;
174
176
this . _transitionCheckState (
175
177
this . _checked ? TransitionCheckState . Checked : TransitionCheckState . Unchecked ) ;
@@ -179,7 +181,7 @@ export class MdCheckbox implements ControlValueAccessor {
179
181
/**
180
182
* Whether the checkbox is indeterminate. This is also known as "mixed" mode and can be used to
181
183
* represent a checkbox with three states, e.g. a checkbox that represents a nested list of
182
- * checkable items. Note that whenever `checked` is set, indeterminate is immediately set to
184
+ * checkable items. Note that whenever `checked` is set to true , indeterminate is immediately set to
183
185
* false. This differs from the web platform in that indeterminate state on native
184
186
* checkboxes is only remove when the user manually checks the checkbox (rather than setting the
185
187
* `checked` property programmatically). However, we feel that this behavior is more accommodating
You can’t perform that action at this time.
0 commit comments