I have a file 'nvi.json' which looks like this:
[
{
"abbrev": "gn",
"book": "Gênesis",
"chapters": [
{
"1": {
"1": "...",
"2": "..."
}
},
{
"2": {
"1": "...",
"2": "..."
}
},
{
"3": {
"1": "...",
"2": "..."
}
}
]
}
]
And I'm accessing this way:
export class BookPage {
public chapters: Array<string>;
private url: any = "../../assets/nvi.json";
constructor(public navCtrl: NavController, private NavParams: NavParams, public http: Http) {
let id = NavParams.get('id');
this.http.get(this.url).map(res => res.json())
.subscribe(data => {
this.chapters = data[id].chapters[0];
console.log(this.chapters);
});
}
'this.chapters' returns the first chapter where it contains the verses.
But I'm not able to loop these verses.
<div *ngFor="let item of chapters">
{{item}}
</div>
Console:
EXCEPTION: Error in ./BookPage class BookPage - inline template: 33: 5 caused by: Can not find a supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.