2014-02-12 25 views
0

我試圖從模板獲取內容到視圖類。無法從視圖類獲取內容值

{{view App.IssueView contentBinding='controller.content'}} 

model.name在模板中顯示正常,但是當我嘗試訪問視圖類中的content.name時。它顯示未定義。

define(['app'], function(App){ 

App.IssueView = Ember.View.extend({ 
    tagName: 'ul', 
    templateName: "magazines/show/issues", 
    didInsertElement: function() { 

     var controller = this.get('controller'); // showing Class 

     console.log(controller.content); // Showing the Model 
     console.log(controller.content.name); // undefinded 

    } 

}); 

return App.IssueView; 

}); 

請幫幫我。謝謝。

+0

嘗試'{{view App.IssueView}}'(無內容綁定)。並且:'this.get('controller.model.name')' – edpaez

+0

我試過了。但相同的未定義的節目。 – Ahmed

+1

這個工程? controller.get('content.name')或有可能名稱尚未加載 – fanta

回答

0

因爲模型沒有加載那個時間。這是一個同步的承諾,它必須由Ember.Deffered解決。