diff --git a/src/demo-app/checkbox/checkbox-demo.html b/src/demo-app/checkbox/checkbox-demo.html index 73fdfc6e2c91..28760dac161c 100644 --- a/src/demo-app/checkbox/checkbox-demo.html +++ b/src/demo-app/checkbox/checkbox-demo.html @@ -1,7 +1,8 @@

md-checkbox: Basic Example

{ expect(document.activeElement).toBe(inputElement); }); + it('should forward the value to input element', () => { + testComponent.checkboxValue = 'basic_checkbox'; + fixture.detectChanges(); + + expect(inputElement.value).toBe('basic_checkbox'); + }); + describe('ripple elements', () => { it('should show ripples on label mousedown', () => { @@ -349,7 +356,6 @@ describe('MdCheckbox', () => { expect(checkboxNativeElement.querySelectorAll('[md-ripple]').length) .toBe(1, 'Expect [md-ripple] in checkbox'); })); - }); describe('color behaviour', () => { @@ -694,6 +700,7 @@ describe('MdCheckbox', () => { [disabled]="isDisabled" [color]="checkboxColor" [disableRipple]="disableRipple" + [value]="checkboxValue" (change)="changeCount = changeCount + 1" (click)="onCheckboxClick($event)" (change)="onCheckboxChange($event)"> @@ -713,6 +720,7 @@ class SingleCheckbox { lastKeydownEvent: Event = null; changeCount: number = 0; checkboxColor: string = 'primary'; + checkboxValue: string = 'single_checkbox'; onCheckboxClick(event: Event) {} onCheckboxChange(event: MdCheckboxChange) {} diff --git a/src/lib/checkbox/checkbox.ts b/src/lib/checkbox/checkbox.ts index 14e7d642be5e..719aa600b0d7 100644 --- a/src/lib/checkbox/checkbox.ts +++ b/src/lib/checkbox/checkbox.ts @@ -151,6 +151,9 @@ export class MdCheckbox implements ControlValueAccessor { /** Event emitted when the checkbox's `indeterminate` value changes. */ @Output() indeterminateChange: EventEmitter = new EventEmitter(); + /** The value attribute of the native input element */ + @Input() value: string ; + /** The native ` element */ @ViewChild('input') _inputElement: ElementRef;