'Angular: access to variable which is declared inside subscribe function
i need to get access to the variable 'u' from subscribe ( they are all in the ngOnInit )
this.currentUser = this.tokenStorageService.getUser();
this.userService.getAdminBoard().subscribe(
data => {
this.content = data;
this.show = true;
console.log('test')
this.u = this.currentUser; // this one
console.log(this.u) ;
},
err => {
this.content = JSON.parse(err.error).message;
this.show = false;
}
);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
