问题描述
我有一个 ember 应用程序,插座和连接插座的概念很好,我明白了.我不明白的是如何在没有疯狂嵌套的情况下在另一个视图/控制器视图中拥有多个视图/控制器视图
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
假设我正在设计 icloud 克隆,其中有电子邮件功能和照片库功能.现在如果我想完成类似
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
我可以将这些热交换到 SplitView 的级别或将它们全部删除,但我认为只允许一个 outlet
这样做的好方法.它会迫使我在不应嵌套的事物中进行下一步操作.使用单出口方法,我的结构看起来更像
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
我如何找到一种适合 Ember.js/Router 的架构风格,并且仍然允许更复杂的嵌套?
How would I find an architecture style that fits with Ember.js/Router that still allows for more complex nesting?
推荐答案
你知道你能说出网点的名字吗?例如,在 SplitView 模板中,你可以有一个 {{outlet inboxListView}},一个 {{outlet contactsListView}} 等等……当你做 connectOutlets 的时候,你可以这样做:
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'})
等等...
这篇关于Ember.js 路由器应用程序架构——如何拥有多个嵌套的视图/控制器对的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!