我不太确定我是否完全理解你的问题.
Is there a pattern that enables this kind of ‘on-demand-loading’ of components and their templates in ng2?
but they should be able to share services and libraries.
Angulars指南建议共享模块和核心模块.实际上我认为这是最好的方法.只需在上面的链接上向下滚动即可.
Each component is able to communicate its capabilities (in the form of a NG2 component) as well as the protocol implementation and the necessary GUI elements (HTML/CSS) via a package sent over the very same websocket connection.
这是我不确定的部分,就像我不知道我是否理解你的意思.您不想通过websocket连接加载组件吗?如果是这样,为什么呢?如果你的意思是只对每个具有相同websocket的组件进行通信:我建议服务这样做,这将是核心模块的一部分,因此是一个单身人士.然后,组件可以访问此服务,因此它们始终连接到相同的websocket.