Emberjs 开发了一个独立的组件,它有自己的路由/状态,可以集成到主应用程序中 [英] Emberjs develop a component in isolation with its own routing/states, which can be integrated to main app

查看:11
本文介绍了Emberjs 开发了一个独立的组件,它有自己的路由/状态,可以集成到主应用程序中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 ember 中开发一个组件.

I need to develop a component in ember.

组件逻辑与主应用程序有些隔离,可以创建为单独的隔离应用程序,在组件内具有状态和路由.

The component logic is somewhat isolated from main application and can be created as a seperate isolated application, with states and routes within the component.

目前我将组件的根控制器设为ApplicationController"以启用路由,名称applicationController"看起来像硬编码.

Presently I have root controller of component as 'ApplicationController' to enable routing, the name 'applicationController' looks like hard coded.

现在我有了带有ApplicationController"+相关路由的主应用程序,以及我的组件及其ApplicationController"+ 相关路由.看起来很难整合它们.

Now I have the main application with its 'ApplicationController' + related routing, and my component with its 'ApplicationController' + related routing. It looks hard to integrate them.

有没有办法让像这样的多个组件分隔我的命名空间?查看评论此处

Is there any way to have multiple components like this seperated my namespaces? See comments here

因此,主要关注的是一种独立开发具有路由/状态的 ember 组件的方法,该方法易于与也具有路由/状态的主应用程序集成.

So the main concern is a method to develop an ember component with routin/states in isolation, that is easy to integrate back with main application which also has routing/states.

编辑

我在组件中有两个值,它们绑定到唯一的集成主应用程序.此外,组件路由一旦集成就必须作为应用程序路由的一部分.

I have two values in component that is bound to main application that is the only integration. Also component routes must come as part of application route once integrated.

Eg: #/approuteforcomponent/componentroute/componentroute2/

在开发过程中我应该能够做到

While developing I should be able to do just

#/approuteforcomponent  -- shows a page saying component under construction
#/componentroute/componentroute2/

话虽如此,我现在的主要问题是关于使用ApplicationControler"的主应用程序和组件

That being said, the main issue I have now is about both main application and component using 'ApplicationControler

更新

类似问题

ember.js 是否鼓励过多的控制器?>

推荐答案

回到主应用程序,您希望实现的集成程度是多少?我的意思是:想要的隔离只与代码结构有关吗?或旨在分解组件重用?

What is the degree of integration you wish to achieve, back with main application? I mean: is the wanted isolation only related to code structure? or aims to factorized components reuse?

是主要的应用程序和组件路由真的无关吗?

Are main app & component routing really unrelated?

您至少有两种可能的方法:

You have at least two possible approaches:

  • 您可以设置多个 ember 应用程序,它们之间可能存在弱关系,但是路由依赖于浏览器的基本状态,因此让多个路由器同时实例化与并发位置管理听起来似乎没有意义..

  • You could setup several ember applications, with possible weak relations between them, but the routing relies on browser's base state, so it does not sounds like it makes sense to have several routers instanciated simultaneously with concurrent location management...

您还可以使用插件架构开发您的应用,让插件重新打开主应用的路由,以及应用与应用之间更紧密的关系.插件(这就是我们在我工作的地方所做的......)

You also could develop your app with an addons architecture, having addons reopening the main app's routes, and stronger relations between app & addons (that's what we are doing here where I am working...)

这篇关于Emberjs 开发了一个独立的组件,它有自己的路由/状态,可以集成到主应用程序中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆