diff --git a/src/components/input/input.html b/src/components/input/input.html index f177fd3870a5..d905b20ce6ce 100644 --- a/src/components/input/input.html +++ b/src/components/input/input.html @@ -1,4 +1,4 @@ -
+
diff --git a/src/components/input/input.ts b/src/components/input/input.ts index c90d27ae0a4c..681e28e7687b 100644 --- a/src/components/input/input.ts +++ b/src/components/input/input.ts @@ -9,6 +9,8 @@ import { ContentChild, SimpleChange, ContentChildren, + ViewChild, + ElementRef, QueryList, OnChanges, } from '@angular/core'; @@ -93,6 +95,7 @@ export class MdHint { templateUrl: 'components/input/input.html', styleUrls: ['components/input/input.css'], providers: [MD_INPUT_CONTROL_VALUE_ACCESSOR], + host: {'(click)' : 'focus()'} }) export class MdInput implements ControlValueAccessor, AfterContentInit, OnChanges { private _focused: boolean = false; @@ -154,6 +157,14 @@ export class MdInput implements ControlValueAccessor, AfterContentInit, OnChange // Input though, so we use HostBinding. @HostBinding('attr.align') private get _align(): any { return null; } + + @ViewChild('input') private _inputElement: ElementRef; + + /** Set focus on input */ + focus() { + this._inputElement.nativeElement.focus(); + } + /** @internal */ onFocus() { this._focused = true;