Emberjs-1.0.0-rc.6 using enumerable to list events occurring on a particular date

前端 未结 1 493
心在旅途
心在旅途 2021-01-27 19:10

When I define a controller action to display dates occuring a particular date, it works correctly, but If I convert that controller action to a property it stops displaying the

1条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-27 19:54

    It looks like you need to add 'content.@each' to your computed property.

    As it stands now 'todayEvent' will only be computed when 'date' changes I am guessing date is being set before or at the same time as the content.

    todayEvent is returning [false, false] because you are using map not filter.

    todayEvent: function(){
      var _self = this;
      var appoint = _self.get('controllers.appointments');
      var appCont = appoint.get('content');
    
      return appCont.filter(function(appointee) {
        return (moment(appointee.get('event.start')).unix() == moment(_self.get('date')).unix());    
      });
    }.property('content.@each', 'date')
    

    0 讨论(0)
提交回复
热议问题