Skip to content

Commit 3bb667e

Browse files
feloyjelbourn
authored andcommitted
docs: document MdInput focus() method (#1486)
1 parent e4af65a commit 3bb667e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/lib/input/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,25 @@ The divider (line under the `<md-input>` content) color can be changed by using
8686

8787
You can label the `<md-input>` as you would a regular `<input>`.
8888

89+
## Focus
8990

91+
You can put the focus on an input component using the `focus()` method.
92+
93+
### Example
94+
95+
```html
96+
<md-input #nameInput placeholder="name"></md-input>
97+
```
98+
99+
```ts
100+
export class MyComponent implements OnInit {
101+
@ViewChild('nameInput') nameInput: MdInput;
102+
103+
ngOnInit() {
104+
this.nameInput.focus();
105+
}
106+
}
107+
```
90108

91109
## Full Forms
92110

0 commit comments

Comments
 (0)