0
我已經把下面的json放到了一個名爲logs的數組中,並且希望使用創建的時間戳對每週進行分組。如何在打字稿/離子2中按星期分組時間戳?
{
created : "2017-07-15 09:49:37"
entry : "this is a log entry"
}
created : "2017-07-13 09:49:37"
entry : "this is a log entry"
}
{
created : "2016-05-13 11:00:21"
entry : "this is another log entry"
}
和離子2 html。
<div *ngFor="let log of logs">
<ion-list-header>
{{log.created}}
</ion-list-header>
<ion-item>
{{log.entry}}
</ion-item>
</div>
編輯
好,我現在在做PHP每週分組返回下面的JSON,
"payload": {
"logs": {
"19": [
"[{\"entry\":"this is an entry",\"created\":\"2017-05-12 09:51:18\"}]"
],
"28": [
"[{\"entry\":"this is an entry",\"created\":\"2017-07-15 09:50:50\"}]",
"[{\"entry\":"this is an entry",\"created\":\"2017-07-15 09:51:18\"}]"
]
}
我收到像這樣,
private weeks: any[];
this.api.getLogs().subscribe(
data => {
// Success
this.weeks = data.payload.logs;
},
err => {
//Err
}
);
,我試圖在Ionic 2中使用它,
<div *ngFor="let week of weeks">
<div *ngFor="let log of week">
{{log.created}}
</div>
</div>
但給了我下面的錯誤,
Runtime Error
Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.
任何幫助表示讚賞。
感謝
請問您能告訴我們到目前爲止您嘗試了些什麼? – sebaferreras
嗨,我已編輯帖子以顯示我目前的情況。我已經在PHP方面分了幾周,但我有問題讓json進入列表。 – Dunny