Ember.js 如果根据过滤条件更改模型记录,如何计算模型记录的长度?

Ember.js 如果根据过滤条件更改模型记录,如何计算模型记录的长度?,ember.js,ember-data,Ember.js,Ember Data,我已经发布了我的代码 在点击type1和type2链接时,我在某种情况下过滤数据,由于这种过滤,我无法计算每个场景中的记录总数 我应该能够计算每个过滤中的记录总数和类型1、类型2的记录总数 App.IndexController = Ember.ArrayController.extend({ total:function(){ return this.get('content.length'); }.property('conten

我已经发布了我的代码

在点击type1和type2链接时,我在某种情况下过滤数据,由于这种过滤,我无法计算每个场景中的记录总数

我应该能够计算每个过滤中的记录总数和类型1、类型2的记录总数

App.IndexController = Ember.ArrayController.extend({
         total:function(){ 
           return this.get('content.length'); 
         }.property('content.length'),
         total1: function() {
           return this.get('content').filterProperty('contacttype', 1).get('length');
         }.property('content.@each.contacttype'),
         total2:function(){ 
           return this.get('content').filterProperty('contacttype', 2).get('length');
         }.property('content.@each.contacttype')
    });

好的,事情是这样的,对于ember中引入的新路由器,每次您重写“setupController”方法时,您都需要再次将控制器和模型发送到“super”,这是ember开发人员为什么这样做的一个解释,您可以在internet上找到它,因此,您必须这样做:

App.IndexRoute = Ember.Route.extend({
  setupController: function (controller, model) {
    this._super(controller, model);
    var cont = App.Person.find();
    controller.set('filtereddata', cont);
  },
  model: function() {      
    return App.Person.find();
  }
});

您还需要对其他路径执行同样的操作。

@inuitivepixel是的,它在单一条件下工作正常,即如果所有记录都没有任何过滤。但是对于多次过滤,我已经发布了这个新问题。@inuitivepixel:很抱歉,我现在会给您适当的反馈。