2014-01-16 74 views
2

我會得到一個對象的belongsTo關係。什麼是最好的方法?我發現方法'didInsertElement'中的recordingFact對象不是null。我看到了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 

    } 
}) 
+0

什麼'recordingFact.get( 'recordsString'),然後(函數(響應){...})'? – claptimes

回答

0

這是爲我工作,你確定你正在傳遞一個承諾,或者你確定在模型中存在的財產?

您可以登錄出來檢查

<div class="panel-body"> 
    {{log model.recordingFact}} 
    {{alert-chart recordingFact=model.recordingFact}} 
</div> 

http://emberjs.jsbin.com/OxIDiVU/133/edit