I'm learning Angular 4. I am trying to display the results of a call to my backend API. I'm getting the data fine. I want to display it. Here is the component:
import { Component, OnInit } from '@angular/core';
import { QuizService } from '../services/quiz.service';
@Component({
selector: 'board',
templateUrl: './board.component.html',
styleUrls: ['./board.component.css']
})
export class Board {
constructor(private service: QuizService) {}
quizzes: any[];
ngOnInit() {
this.service.getQuizzes()
.subscribe(res => {
this.quizes = res.json();
console.log(this.quizzes)
}), error => {
console.error(error)
}
}
}
Here is where I am attempting to use ngFor:
<div className="board">
<div className="board-container">
<li *ngFor="let quiz of quizzes">
{{ quiz.title }}
</li>
</div>
</div>
This raises this error:
"Board.html:3 ERROR Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays."
I'm following a tutorial and have done similar things before... can't figure out what I'm doing wrong here. The data IS coming through.