Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/components/input/input.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
[attr.aria-required]="ariaRequired"
[attr.aria-invalid]="ariaInvalid"
[id]="inputId"
[attr.min]="min"
[attr.max]="max"
[disabled]="disabled"
[required]="required"
[spellcheck]="spellcheck"
Expand Down
16 changes: 16 additions & 0 deletions src/components/input/input.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,22 @@ export function main() {
expect(testComponent.onBlur).toHaveBeenCalledWith(fakeEvent);
})();
});

it('supports min and max attributes for number fields', () => {
return builder
.overrideTemplate(MdInputNumberTypeConservedTestComponent, `
<md-input type="number" [(ngModel)]="value" min="0" max="10">
</md-input>
`)
.createAsync(MdInputNumberTypeConservedTestComponent)
.then(fixture => {
const inputElement: HTMLInputElement = fixture.debugElement.query(By.css('input'))
.nativeElement;

fixture.detectChanges();
expect(inputElement.getAttribute('min')).toBe('0');
expect(inputElement.getAttribute('max')).toBe('10');
});
});
});
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/input/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ export class MdInput implements ControlValueAccessor, AfterContentInit, OnChange
@Input() @BooleanFieldValue() required: boolean = false;
@Input() @BooleanFieldValue() spellcheck: boolean = false;
@Input() type: string = 'text';
@Input() max: number = null;
@Input() min: number = null;

private _blurEmitter: EventEmitter<FocusEvent> = new EventEmitter<FocusEvent>();
private _focusEmitter: EventEmitter<FocusEvent> = new EventEmitter<FocusEvent>();
Expand Down