I’m creating a detail page where an injected simple http provider fetches a remote json file and assigns the data to a property postDetailData of PageClass. I’m able to console-log the data at PageClass level and its type successfully.
Remote Json File Contents:
{
"postImage" : "build/assets/feed-img-1.jpg",
"postTitle" : "Top tips for programming",
"postCategory" : "Events",
"postContent" : "Lorem ipsum dolor sit amet.",
"postCommentCount" : 353,
"postNumberOfShares" :94,
"postNumberOfLikes" : 42
}
Class Function
public loadFeed() {
let loader = this.createLoader();
loader.present();
this.jsonApi.load("/api/single-post.json")
.then(data => {
if (data.ErrorStatus) {
alert("Failure!");
loader.dismiss();
}
else
{
this.postDetailData = data;
console.log(this.postDetailData); //using typeof confirms as object
loader.dismiss();
}
})
}
However, using dot notation of this property in my template gives an undefined error message:
Even though postDetailData is accessible in template (using json pipe), I cannot access the children.
I’ve searched online for hours on end and still can’t figure out why. Any help would be awesome.