我有下面的模板設置顯示的項目清單,並在其自己的控制器包裝每一個列表:堅持客體控制器細節
{{#each controller itemController="contact"}}
<div class="contact-entry">
<div class="title" {{action toggle on="click"}}>{{title}}</div>
{{#if showDetails}}
<div class="details">
<div>{{safe details}}</div>
</div>
{{/if}}
</div>
{{/each}}
主控制器是一個ArrayController稱爲ContentsController
,並且每個項目被包裹在一個名爲ContentController
的ObjectController。該ContentsController
的內容在路線明確設置(我已經簡化了數據):
App.ContactsRoute = Em.Route.extend({
model: function() {
return [{'title': 'first'}, {'title': 'second'}];
}
});
這個作品真的很好。但是,如果我導航到另一個路徑,然後再返回,ContentController
上的設置不會持續。會發生什麼是模型數據重新加載,並且我假設爲每個列表項目創建了一個ObjectController。順便提一下,ContentsController
不是這種情況,它保持其設置。
什麼是防止每次訪問頁面時爲每個列表項目創建新的ContentController
炭燼的解決方案?
那麼我如何讓contactController持久。我需要改變什麼才能使它起作用? – Gevious