angularjs filter (not working)

前端 未结 7 1347
灰色年华
灰色年华 2020-12-25 14:56

The following HTML, Javascript and JSON render correctly, but the filter does not work at all. What are we doing wrong?



        
7条回答
  •  佛祖请我去吃肉
    2020-12-25 15:52

    As Narretz already mentioned, Angular filters cannot handle an object of objects as input. But you can write your own simple filter converting the object of objects into an array of objects. You can use the angular filters behind your array filter by chaining.

    Your array filter could be as simple as this:

    app.filter('array', function() {
      return function(items) {
        var filtered = [];
        angular.forEach(items, function(item) {
          filtered.push(item);
        });
       return filtered;
      };
    });
    

提交回复
热议问题