问题
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