1

Probably a silly question.
I got the following javascript (typescript to be honest, I don't know if it's useful to know) code.

richiesta: Richiesta;

loadDataForm(id: number){

    this.richiesteSrv.getRichiesta(id)
      .then(r => {
        this.richiesta = r;
        console.log('Inside log', this.richiesta);
      });

      console.log('Outsidelog', this.richiesta);

  }

Why does the inside log show correctly the updated value but the outside log doesn't? I'm aware of varibale scope, but since this.richiesta is a class variable shouldn't the function change its value, and so the update value be available outside?
Thanks for the clarifications.

esseara
  • 834
  • 5
  • 27
  • 47

0 Answers0