Closed FahadAlbukhari closed 6 years ago
orderBy
is applied right after array in *ngFor
is changed
Hi i used the below code after installing the Ng2OrderModule.but its not ordering the list by the type field.what i am doing wrong please let me know.
<div *ngFor="let favorite of favoriteReports | orderBy: 'favorite.type'" title="{{favorite.title}}" class="row-striped">
<a [routerLink]="['/report/documentList',{reportId:favorite.id}]"
*ngIf="favorite.type=='Report'" (click)="selectFavorite(favorite,$event)">
<i class="fa fa-file-text"></i> {{favorite.title}}</a>
<a [routerLink]="['/report/', favorite.folderPathId]" *ngIf="favorite.type!='Report'"
(click)="selectFavorite(favorite,$event)">
<i class="fa fa-folder-open"></i> {{favorite.title}}</a>
</div>
Try to install ngx-order-pipe
(see installation and usage in the documentation) instead of ng2-order-pipe
.
The refresh is not working for me either.
*ngFor="let myItem of myObject.myItems | orderBy: 'itemOrder'"
itemOrder is a property off myItem. I had to add the ticks ' for it to work as well which I did not see in the example.
@VadimDez
The refresh is not working for me either.
<li *ngFor="let address of addresses | orderBy:'validFrom':true; let i = index">
validFrom is a prop of address and the type is Date.
After adding an address
to addresses
and also changing the value of a validFrom
the list does not reorder as expected.
works if the pipe is stateful
@Pipe({
name: 'orderBy',
pure: false
})
Fixed in latest version 1.1.0
of ngx-order-pipe
.
Thanks @ESimmonds for pointing that out.
Thanks @VadimDez
How to refresh the order automatic on any changes of the *ngFor?