This is the code I have written in angular/ionic
this.http.get('/assets/xml/app.xml').subscribe(data => {
xml2js.parseString(data.text(), function(err, result) {
console.log('result', result);
this.posts = JSON.stringify(result);
console.log('type of', this.posts);
});
}, error => {
console.log(JSON.stringify(error.json()));
});
This function throws following error when assigning the result to the post variable.
Cannot set property 'posts' of undefined