2012-03-16 84 views
0

我有一個包含最近搜索項的列表的數組控制器。當我將一個項目推送到數組時,它正確顯示了視圖上的項目數量,除了一個問題之外......我無法獲取要打印的名稱。每個迭代器不輸出內容數組的值

下面是相關代碼

App.recentUsersArray = Em.ArrayController.create({ 
    content: [], 
    addUser: function(name) { 
     this.pushObject(name); 
    } 
}); 

<ol> 
    {{#each App.recentUsersArray}} 
     <li> 
      {{#view App.RecentNameView}} {{name}} {{/view}} 
      {{#view App.RecentNameDeleteView}}X{{/view}} 
     </li> 
    {{/each}} 
</ol> 

這裏面行:{{#view App.RecentNameView}} {{/view}}我試過{{name}}{{content.name}}但都不起作用。我究竟做錯了什麼?

回答

1

嘗試使用 「這個」:http://jsfiddle.net/s7DbE/

還是這個,這是回答這個問題的好一點:http://jsfiddle.net/s7DbE/1/

還是這個小提琴,其反轉輸入:http://jsfiddle.net/s7DbE/2/

+0

{{此}}在RecentNameView裏面只打印出對象字符串。 – commadelimited 2012-03-16 14:31:16

+0

更新我的解決方案 – Fadi 2012-03-16 14:38:21

+0

太好了。謝謝Fadi!與contentBinding完美配合。 – commadelimited 2012-03-16 14:52:49