Я относительно новичок в Angular8 (2).
Как я могу отправить userInformation в другой компонент, называемый настройками, и отобразить его на странице? и если что-то изменится, обновите автоматически.
Любая помощь очень ценится.
export interface UserInfoModel {
id: string;
email?: string;
firstName?: string;
lastName?: string;
mobile?: string;
createdAt: string;
}
private userInformation: UserInfoModel;
this.http
.post<RequestResponse>(`${API_BASE_URL}user/login`, loginData)
.pipe(catchError(this.errorHandler))
.subscribe(response => {
const token = response.content.token;
const userId = response.content.id;
const email = response.content.email;
// added to UserInfo
this.userInformation = {
id: response.content.id,
email: response.content.email,
firstName: response.content.firstName,
lastName: response.content.lastName,
mobile: response.content.lastName,
createdAt: response.content.createdAt
};
this.token = token; // add token to local var
this.userId = userId;
}