2017-10-21 113 views
0

* ngForディレクティブのユーザー注文モジュールを手伝ってください。* ngForで逆順にする方法は?

私は "NGX-オーダー・パイプ" をインストールします。 "^ 1.0.2"、およびapp.module.tsでそれを使用します。

import { OrderModule } from 'ngx-order-pipe'; 
... 
.. 

@NgModule({ 
    declarations: [ 
    AppComponent 
    ], 
    imports: [ 
    OrderModule, 
    ... 
    .. 
    ], 
    providers: [AgendaService], 
    bootstrap: [AppComponent] 
}) 
export class AppModule { } 

マイテンプレート:

<div class="line" *ngFor="let line of agenda | orderBy:'order'; let iLine = index"> 
    <div class="left"> 
    {{ line.start.trim() }} - {{ line.end.trim() }} 
    = {{line.order}} 
    </div>  
</div> 

それは働いていました(行は昇順にソートされます)。しかし、降順ソートされた線が必要です。

私がフォローしてみてください:

<div class="line" *ngFor="let line of agenda | orderBy:'-order'; let iLine = index"> 
    .....  
</div> 

をしかし、それは働いていません。

GITHUB is here

+0

どのように機能しませんでしたか?何が起こると思いますか?実際に何が起こったのですか? –

答えて

1

ngx-order-pipeはこの構文は次のとおりです。で、この程度

*ngFor="let line of agenda | orderBy:'order':true; let iLine = index"

より:

{{ collection | orderBy: expression : reverse }}

だから、降順使用するには、二番目のパラメータを使用する必要があります彼らのギター:

https://github.com/VadimDez/ngx-order-pipe

関連する問題