Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

218
Visualizações
Angular service in MatDialog leads to Uncaught ReferenceError

I want to open the components as a dialog via the use case service. The dialog itself contains the use case service to call functions. Unfortunately an Uncaught ReferenceError: Cannot access 'f' before initialization occurs in the following implementation. Why does the error occur and how can I solve it?

The problem occurs because the dialog is opened in the use case or the dialog then contains the use case. If I call another component, the error does not occur. The error also does not occur if I remove the use case service from the component.

@Injectable()
export class ManageRuleBuilderDialogUsecase {
  constructor(
    private store: Store,
    private dialog: MatDialog,
  ) {}

  public openEmptyRuleBuilderDialog(): void {
    this.dialog.open(RuleBuilderDialogComponent, {
      width: modalWidth,
      height: modalHeight,
    });
  }

  public addAction(): void {
    ...
  }
}
@Component({...})
export class RuleBuilderDialogComponent implements OnInit {
 constructor(
    private store: Store,
    private dialog: MatDialogRef<RuleBuilderDialogComponent>,
    private manageRuleBuilderDialogUsecase: ManageRuleBuilderDialogUsecase
  ) {}

  public onAddAction(): void {
    this.manageRuleBuilderDialogUsecase.addAction();
  }
  ...
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda