admin管理员组文章数量:1435797
Please help user order module in *ngFor directive.
I install "ngx-order-pipe": "^1.0.2", and use it in app.module.ts:
import { OrderModule } from 'ngx-order-pipe';
...
..
@NgModule({
declarations: [
AppComponent
],
imports: [
OrderModule,
...
..
],
providers: [AgendaService],
bootstrap: [AppComponent]
})
export class AppModule { }
My template:
<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>
It worked (lines sorted ascending). But i need lines sorted descending.
I try follow:
<div class="line" *ngFor="let line of agenda | orderBy:'-order'; let iLine = index">
.....
</div>
But it not worked.
GITHUB is here
Please help user order module in *ngFor directive.
I install "ngx-order-pipe": "^1.0.2", and use it in app.module.ts:
import { OrderModule } from 'ngx-order-pipe';
...
..
@NgModule({
declarations: [
AppComponent
],
imports: [
OrderModule,
...
..
],
providers: [AgendaService],
bootstrap: [AppComponent]
})
export class AppModule { }
My template:
<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>
It worked (lines sorted ascending). But i need lines sorted descending.
I try follow:
<div class="line" *ngFor="let line of agenda | orderBy:'-order'; let iLine = index">
.....
</div>
But it not worked.
GITHUB is here
Share Improve this question edited Oct 21, 2017 at 10:22 Martin Adámek 18.5k5 gold badges48 silver badges71 bronze badges asked Oct 21, 2017 at 9:33 super.prozandr1super.prozandr1 1273 silver badges10 bronze badges 1- How did it not work? What did you expect to happen? What id actually happen? – Lazar Ljubenović Commented Oct 21, 2017 at 9:36
1 Answer
Reset to default 3The ngx-order-pipe
has this syntax:
{{ collection | orderBy: expression : reverse }}
So to use descending order, you need to use second parameter:
*ngFor="let line of agenda | orderBy:'order':true; let iLine = index"
More about this on their github:
https://github./VadimDez/ngx-order-pipe
本文标签: javascriptHow to reverse order in *ngForStack Overflow
版权声明:本文标题:javascript - How to reverse order in *ngFor? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745615469a2666374.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论