0

我已经在这里发布了我的代码。

单击 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')
    });
4

1 回答 1

1

好的,事情就是这样,对于 ember 中引入的新路由器,每次覆盖 'setupController' 方法时,都需要再次将控制器和模型发送给 'super' ,有一个解释为什么 ember 开发人员这样做这个,你可以在互联网上找到它,所以,你必须这样做:

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();
  }
});

您还需要对其他路线做同样的事情

于 2013-08-12T01:06:42.787 回答