diff --git a/src/demo-app/checkbox/checkbox-demo.html b/src/demo-app/checkbox/checkbox-demo.html index 713f8b008d4c..e3571e79ec7c 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('color behaviour', () => { it('should apply class based on color attribute', () => { testComponent.checkboxColor = 'primary'; @@ -630,6 +637,7 @@ describe('MdCheckbox', () => { [indeterminate]="isIndeterminate" [disabled]="isDisabled" [color]="checkboxColor" + [value]="checkboxValue" (change)="changeCount = changeCount + 1" (click)="onCheckboxClick($event)" (change)="onCheckboxChange($event)"> @@ -648,6 +656,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 f89f3146df3a..90a22910fce8 100644 --- a/src/lib/checkbox/checkbox.ts +++ b/src/lib/checkbox/checkbox.ts @@ -147,6 +147,9 @@ export class MdCheckbox implements ControlValueAccessor { /** Event emitted when the checkbox's `checked` value changes. */ @Output() change: EventEmitter = new EventEmitter(); + /** The value attribute of the native input element */ + @Input() value: string ; + /** The native ` element */ @ViewChild('input') _inputElement: ElementRef;