2016年3月9日 星期三

Angular orderBy/filter not working with ng-repeat 無法在 Angular 使用排序過濾功能


Issue 問題:
orderBy / filter function not working with ng-repeart item .

在 ng-repeat 時,無法使用 orderBy 或 filter 功能


p.s. ordeBy/filter can only works with arrays, not for objects.
註. orderBy/filer 只能作用在 arrays ,objects 無法使用



Environment 環境: 

AngularJS: 1.5


Solution 解決方式: 


Step 1. download and include "ng-order-object-by.js"  from https://github.com/fmquaglia/ngOrderObjectBy.
步驟 1. 從 https://github.com/fmquaglia/ngOrderObjectBy. 下載並加入 "ng-order-object-by.js"



Step 2. include this module in your module: angular.module('myModule', ['ngOrderObjectBy']);
步驟 2.在自己的 module 中加入此 module:angular.module('myModule', ['ngOrderObjectBy']);

Step 3. replace orderObjectBy: with orderBy
步驟 3. 使用 orderObjectBy: 取代原本的 orderBy


Step 4. filter also works now
Step 5. filter 功能也可正常使用了


Ref 參考:
http://stackoverflow.com/questions/19387552/angular-cant-make-ng-repeat-orderby-work
https://github.com/fmquaglia/ngOrderObjectBy

1 則留言:

  1. Casino Review | Player Rating - DRMCD
    A 안동 출장샵 comprehensive casino 경상북도 출장마사지 review and rating based on 양산 출장마사지 real players' reviews 세종특별자치 출장안마 and 김천 출장안마 ratings by the casino. Learn about games, promotions, games,  Rating: 3.4 · ‎Review by Dr

    回覆刪除