Components promise not work


#1

Hi in my case, I would get an belongsTo relationship of an object. What is the best way? I see that the recordingFact object in method ‘didInsertElement’ ist not null. I see the id.

<script type="text/x-handlebars" data-template-name="alerts/alert">
    <div class="panel panel-primary">
        <div class="panel-heading">
            <h3 class="panel-title"> 
                <i class="glyphicon glyphicon-flash"></i>
                Alert
            </h3>
        </div>
        <div class="panel-body">
                {{alert-chart recordingFact=model.recordingFact}}
        </div>
    </div>
</script>

App.AlertChartComponent = Ember.Component.extend({
    recordingFact: null,
    didInsertElement: function(){

        var recordingFact = this.get('recordingFact'); 
        // if I do some code with promise like .then(function(response){...}) 
        // I get the error recordingFact has no method then
        //
          
        var data = recordingFact.get('recordsString');  // I get undefined 

    }
})

#2

I solved the problem by checking the loading state and then I write an function that would be fired if model state is ‘onLoaded’

App.AlertChartComponent = Ember.Component.extend({
    recordingFact: null,
    didInsertElement: function(){

        var recordingFact = this.get('recordingFact');
        if(!recordingFact.get('isLoaded')){
           recordingFact.on('didLoad', function(){.....});
        }
    }
})