This directive solves the issue of autofocus in angular 2.x, inclusive when you use a dinamically input created before the DOM generation, for example an input created using *ngIf or a hidden input.
You can get it on npm:
npm install ng-autofocus-directive --save
You'll need to add
AutofocusModule to your application module.
Use the directive in your input: