0
が私のコードです:ソートはここ
<div *ngFor="let conv of lender.conversation | orderBy" class="conv-single">
{{conv.date | date: 'dd/MM/yyyy | j'}} - {{conv.text}}
</div>
私はこのようなオブジェクトを持っている:
[{
date: somedate,
text: "text1"
}
...]
そして、ここでは私のORDERBYパイプです:
@Pipe({
name: 'orderBy'
})
export class OrderByPipe implements PipeTransform {
transform(value: any, args?: any): any {
let newVal = value.sort((a: any, b: any) => {
let date1 = new Date(a.date);
let date2 = new Date(b.date);
if (date1 > date2) {
return 1;
} else if (date1 < date2) {
return -1;
} else {
return 0;
}
});
return newVal;
}
}
問題があります私はいつも何が問題なのか誰も知っている同じ順序で要素を得る?
:なぜ、ことを考えるとそうhttp://plnkr.co/edit/HFjmewVizhEVvon8wRjQ?p=preview – silentsod
、 https://angular.io/guide/pipes#appendix-no-filterpipe-or-orderbypipe
を参照してくださいあなたはこのような何かを試すことができますあなたは要素の順序を変更したいですか? – silentsod