Ember.js Router App Architecture — How to have multiple nested view/controller pairs

荒凉一梦 提交于 2019-12-03 07:52:53

问题


I have an ember app and the concept of the outlet and connecting the outlet is fine, I get that. What I don't understand is how to have more than one view/controller view inside of another one without insane nesting

Suppose I am designing icloud clone where I have email functionality and a photo gallery functionality. Now if I wanted to accomplish something like

***********************************************************
* INBOX LIST     **  COMPOSE OR VIEW MESSAGE              *
*                **                                       *
*                **                                       *
*                **                                       *
*                **                                       *
* CONTACTS LIST  **                                       *
*                **                                       *
*                **                                       *
*                **                                       *
*                **                                       *
***********************************************************

The way that I would want to design this would be something like

EmailController/View
|-- SplitViewController/View
   |-- InboxListController/View
   |-- ContactsListController/View
   |-- ComposeMessageController/View
   |-- ReadMessageController/View

Where I can hot swap these to the level of the SplitView or remove them alltogether, but I don't see a good way of doing this with only one outlet allowed. It would force me next things inside of things that should not be nested. Using the single outlet approach, my structure would look more like

EmailController/View
|-- SplitViewController/View
   |-- InboxListController/View
       |-- ContactsListController/View
           |-- ComposeMessageController/View
               |-- ReadMessageController/View

How would I find an architecture style that fits with Ember.js/Router that still allows for more complex nesting?


回答1:


Do you know you can name the outlets ? For example, in SplitView template, you can have one {{outlet inboxListView}}, one {{outlet contactsListView}} etc... when you do your connectOutlets stuff, you can do this like:

splitViewController.connectOutlet({name: 'inboxList', outletName: 'inboxListView'})
splitViewController.connectOutlet({name: 'contactsList', outletName: 'contactsListView'})

and so on...



来源:https://stackoverflow.com/questions/12824917/ember-js-router-app-architecture-how-to-have-multiple-nested-view-controller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!