1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

angular 13 SSR, assign a value to a property in onInit, causes ngOnInit() to be called...

Discussão em 'Angular' iniciado por user26571055, Junho 27, 2025.

  1. user26571055

    user26571055 Guest

    In app.component.ts, I assign a value to a property in onInit, and it used by the HTML template.

    data: any = [];

    ngOnInit() {
    this.service.getData().subscribe(res => this.data = res);
    }


    Any idea why ngOnInit() calls more than once?

    At first, I thought it was the request interface causing this issue. However, after some attempts, I found that assigning a value to it during the lifecycle causes the problem.

    Continue reading...

Compartilhe esta Página