I am updating the angular component properties inside a if block and I feel it is not updating

Discussão em 'Angular' iniciado por Dwarknight, Abril 28, 2025.

  1. Dwarknight

    Dwarknight Guest

    ngOnInit() {


    this.router.events.subscribe(event => {
    if (event instanceof NavigationEnd) {
    if (event.url === '/common/time') {
    this.zone.run(() => {
    setTimeout(()=> {
    this.index = 2;
    this.trial = "Trial";
    console.log(`Inside idx: ${this.index}`);
    }, 100);
    });
    }
    }
    });

    console.log(`Outside idx: ${this.index}`);
    this.loadMonetaryCondition();
    this.loadGoals();
    }


    I have the template like this, the if block is sure executing. But, the values are not updated. I have the template as follows

    <div>Value {{index}} {{trial}}</div>

    Continue reading...

Compartilhe esta Página