import { Component, Inject, Input, OnInit } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { PollService } from '../../../../../core/services/poll.service'; import { DOCUMENT } from '@angular/common'; @Component({ selector: 'app-step-one', templateUrl: './step-one.component.html', styleUrls: ['./step-one.component.scss'], }) export class StepOneComponent implements OnInit { constructor(public pollService: PollService, @Inject(DOCUMENT) private document: any) {} @Input() step_max: any; @Input() form: FormGroup; ngOnInit(): void { this.pollService.step_current = 1; const selector = '#title'; const firstField = this.document.querySelector(selector); if (firstField) { firstField.focus(); } } }