我不知道如何通過我的對象對象(但它應該是數組): Data structureAngular2 rc1 ngFor「無法找到類型爲'object'的不同支持對象'[object Object]'
Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.
視圖結構:
<a *ngFor="let msg of messages " href class="clearfix">
<div class="img-area"><img [ngClass]="{'photo-msg-item': !msg.from}"
src="{{ (msg.from || (msg.from | baProfilePicture)) }}"></div>
<div class="msg-area">
<div>{{ msg.message }}</div>
<span>{{ msg.send_date }}</span>
</div>
</a>
組件:
public notifications:Array<Object>;
public messages:Array<Message>;
public data_error: Boolean = false;
constructor(private _baMsgCenterService:BaMsgCenterService) {
this.messages = this._baMsgCenterService.getMessages().subscribe(
(messagess) => {
let result:Array<Message> = [];
if (messagess) {
messagess.forEach((message) => {
result.push(
new Message(message[0],
message[1],
message[2],
message[3],
message[4])
);
});
}
this.messages = result;
},
err => { this.data_error = true}
);
你可以發佈你的數據是可迭代的,也可以在那裏得到錯誤行號。 ?如果你提供代碼的話,效果會更好。 –