我有一个课程表,我想按日期排序。由于Angular 5没有orderBy管道,到目前为止,我发现的所有解决方案都只能应用于数字和字符串,如果有人可以帮助我,我将不胜感激。这是我桌子的主体
<tbody>
<tr *ngFor="let lesson of lessons">
<th scope="row">{{lesson.date | date:'dd.MM.yyyy H:mm'}}</th>
<td>{{lesson.address.locationName}}</td>
<td>{{lesson.topic}}</td>
<td>{{lesson.homework}}</td>
</tr>
</tbody>
Run Code Online (Sandbox Code Playgroud)
这是我的component.ts文件的片段
public lessons = [];
ngOnInit() {
this.localStorage.getItem<number>('selectedProfileId').subscribe((id) => {
this._profileService.showLessons(id)
.subscribe(data => this.lessons = data,
);
});
}
Run Code Online (Sandbox Code Playgroud)