[
{
"title": "Marker 1",
"innercontent": "the Porcelain Factory"
},
{
"title": "Marker 2",
"innercontent": "The Taj Mahal "
},
{
"title": "Marker 3",
"innercontent": "Golconda Fort"
}
]
The above is my json file.
<div *ngFor="let marker of currentmrkr">
<div>
{{ marker.title }}
</div>
<div>
{{ marker.innercontent }}
</div>
</div>
The above is my html file.
import * as content from './content.json';
marker.addListener("click", () => {for(let item of content){
if(marker.getTitle() == item.title){
this.currentmrkr = item;
}
}
}
The above is in my typescript file.
This shows an error like -
core.js:6260 ERROR TypeError: _content_json__WEBPACK_IMPORTED_MODULE_1___namespace is not iterable
How can we iterate through the json object inside the typescript file in angular and how to import the file into typescript?
forloop orforEach.