I\'ve many input boxes in a div and I need to focus one of them programmatically.
How to do it?
It\'s something like:
Take a look at the ViewChild (and ViewChildren like Gunter suggests) annotations.
You can do something like this:
@Component({
selector: 'samples',
template: `
`
})
export class SamplesComponent {
@ViewChild('input3') input3:ElementRef;
constructor(private _renderer : Renderer) {}
public selectSample() {
//as per Eric's suggestion
this._renderer.invokeElementMethod(this.input3.nativeElement, 'focus', []);
}
}