Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh orderBy after *ngFor is updated? #23

Closed
FahadAlbukhari opened this issue Jul 3, 2017 · 8 comments
Closed

Refresh orderBy after *ngFor is updated? #23

FahadAlbukhari opened this issue Jul 3, 2017 · 8 comments
Assignees
Labels
Milestone

Comments

@FahadAlbukhari
Copy link

FahadAlbukhari commented Jul 3, 2017

How to refresh the order automatic on any changes of the *ngFor?

@FahadAlbukhari FahadAlbukhari changed the title Refresh orderBy after ngModel is updated? Refresh orderBy after *ngFor is updated? Jul 3, 2017
@VadimDez
Copy link
Owner

VadimDez commented Jul 3, 2017

orderBy is applied right after array in *ngFor is changed

@kkamalesh
Copy link

kkamalesh commented Jul 21, 2017

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>&nbsp; {{favorite.title}}</a>
  <a [routerLink]="['/report/', favorite.folderPathId]" *ngIf="favorite.type!='Report'"
     (click)="selectFavorite(favorite,$event)">
    <i class="fa fa-folder-open"></i>&nbsp; {{favorite.title}}</a>
</div>

@VadimDez
Copy link
Owner

Try to install ngx-order-pipe (see installation and usage in the documentation) instead of ng2-order-pipe.

@DigitalMystery
Copy link

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.

@JavanXD
Copy link

JavanXD commented Sep 22, 2017

@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.

@ESimmonds
Copy link

works if the pipe is stateful

@Pipe({
  name: 'orderBy',
  pure: false
})

@VadimDez VadimDez self-assigned this Nov 8, 2017
@VadimDez VadimDez added the bug label Nov 8, 2017
@VadimDez VadimDez added this to the 1.1.0 milestone Nov 8, 2017
VadimDez added a commit that referenced this issue Nov 8, 2017
Fixes #23, made pipe impure to detect all the changes
@VadimDez
Copy link
Owner

VadimDez commented Nov 8, 2017

Fixed in latest version 1.1.0 of ngx-order-pipe.

Thanks @ESimmonds for pointing that out.

@ESimmonds
Copy link

Thanks @VadimDez

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants