it's not same this
inside setTimeout
when you use function(){...
2 most popular ways for this issue:
1) use extra variable to store outside "this"
var that = this;
this.http.post( ...//http variable is defined here
setTimeout(function(){
that.http.post(... //http is not defined here
}
}
2) use arrow functions
this.http.post( ...//http variable is defined here
setTimeout(() => {
that.http.post(... //http is not defined here
}
}
1st way is old ES5 and you don't need any compilers, for ES6 version (#2) you will need to use something like babel.
find more about arrow functions & babel here: https://babeljs.io/docs/learn-es2015/