Skip ng-repeat JSON ordering in Angular JS

后端 未结 4 1722
难免孤独
难免孤独 2020-11-30 06:02

Does anybody know how I can SKIP JSON ordering altogether when I use ng-repeat (in a painless way probably)?

For example, my source JSON looks somet

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-30 06:40

    This answer using filter works best for me.

    https://groups.google.com/d/msg/angular/N87uqMfwcTs/EGoY6O2gtzsJ

    http://jsfiddle.net/er52h/1/

    angular.module('myFilters', [])
      .filter('keys', function() {
        return function(input) {
          if (!input) {
            return [];
          }
          return Object.keys(input);
        }
      });
    

    You can use like this:

提交回复
热议问题