Angular2 RxJS calling class function from map function
Instead of just passing the function
reference use arrow
functions to retain this
.map((res) => this.extractData(res))
Observable's map function allows you to pass a reference variable as a second argument on how should this
actually work inside the higher-order function.
so the solution is.map(this.extractData,this)
This way while passing the extractData function you are also passing the current class's this
execution context to the higher-order function.It will work.