Answer the question
In order to leave comments, you need to log in
What is the correct way to pass one shared object?
There is a user.service.ts service, which has a method:
loadUserData(): Observable<any> {
const url = this.host + '/v1/user';
return this.http.get(url, httpOptions);
}
userService.loadUserData().subscribe(
data => {
this.currentUser = new User(data);
}
);
constructor(protected http: HttpClient) {
super(http);
if (UserService.currentUser == null) {
this.loadUserData().subscribe(
data => {
UserService.currentUser = new User(data);
},
);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question