Last night I did not see this, probably too late. But your problem is not in the this context in the built-in function where you install saveSuccess .
I suggest you use lambdas or the "thick arrow function". Instead
function(data) { ... }
You doing
(data) => { ... }
This will save the this context. Just use it wherever you need the built-in function and you will have no more problems! :)
Your code with lambda function:
export class UserProfileComponent{ saveSuccess: boolean; user: IUser; saveUser(user:IUser) { this.headers = new Headers(); this.headers.append('Content-Type', 'application/json'); this.editUserForm = user; this._http.post('api/user/'+this._current_user._id, JSON.stringify(this.editUserForm),{ headers: this.headers }) .map((data: Response) => data.json)
source share