'Copy value of a local variable to a global variable [duplicate]
I have this variable declared in global scope:
export class InboxmanagementComponent implements OnInit {
statmentID: number; // global variable
displayTaskByIdDetails(){
this._inboxServcie.getTask(this.task.id).subscribe(
(data) => {
this.task = data;
this.statmentID = data.statmentID;
console.log('displaying statementId : ' , this.statmentID); // returns 1 because (data.statementId it's value is 1)
}
);
console.log('displaying statementId : ' , this.statmentID); // returns undefined
}
}
So I would liek to copy the value of this.statementID inside arrow function to the global variable
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
