I updated from Angular 2 to Angular 4 and in the docs it's written to use the Renderer2
instead of Renderer
which is deprecated.
Now am looking into the Renderer source, but cannot find a way to invoke the focus()
method as I used to.
Old method:
this.renderer.invokeElementMethod(element, 'focus', []);
What is the new aproach?
EDIT
What if the element i am focusing onto is obtained via QuerySelector
?
For instance:
let inputField = document.querySelectorAll('.dialog input');
if ( inputField[0] ) {
inputField[0].focus();
}
Since its obtained via QuerySelector
, the focus()
method doesn't exist on it.