Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

217
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!