Help with computed property and template


#1

Given this controller:

export default Ember.Controller.extend({
  isUserAttending: function(){
    var le = this.get('model');

    this.get('session.user.listingEvents')
      .then(function(les){
        var exists = false;

        les.forEach(function(current){
          if (current.id == le.id) {
            exists = true;
          }
        });

        return exists;
    });

  }.property('session.user.listingEvents')
});

why when i do this in my template:

  {{log isUserAttending}}

do i get:

undefined

in my console.

but when debugging I can see that the isUserAttending method is being called and returns the correct values?


#2

sorry for the noise!

fixed with this:

export default Ember.Controller.extend({
  isAttending: false,
  isUserAttending: function(){
    var le = this.get('model');
    var _this = this;

    this.get('session.user.listingEvents')
      .then(function(les){
        var exists = false;

        les.forEach(function(current){
          if (current.id == le.id) {
            exists = true;
            _this.set('isAttending', true)
          }
        });

        return exists;
    });

  }.property('session.user.listingEvents')
});