简体   繁体   English

我如何在rappidjs中的视图之间共享数据

[英]How can I share data between views in rappidjs

I build a menu view component with rappidjs which has a list of entries in it. 我使用rappidjs构建了一个菜单视图组件,该组件中包含条目列表。 I also have some modules. 我也有一些模块。

I want the module to register their menu entry. 我希望模块注册其菜单项。 I thought building a Manager or a collection but this seems way to heave to me. 我本以为建立经理或收藏夹,但这似乎让我感到困惑。 Is there a simple way? 有没有简单的方法?

Implementation can be found here. 可以在这里找到实现。

http://try.rappidjs.com/project/52b0d1e13bce060342000013 http://try.rappidjs.com/project/52b0d1e13bce060342000013

Checkout the rappidjs.com website, it also uses a menu combined with the ModuleLoader. 请访问rappidjs.com网站,该网站还使用了与ModuleLoader结合使用的菜单。

In https://github.com/rappid/rappidjs.com/blob/master/public/app/Index.xml the menu is build with https://github.com/rappid/rappidjs.com/blob/master/public/app/Index.xml中 ,菜单使用

<nav>
    <ui:ItemsView items="{pages}" tagName="ul" class="nav">
         <js:Template name="item">
               <li selected="{isPageSelected(item)}">
                     <a href="${item.link}">${item.label}</a>
               </li>
         </js:Template>
    </ui:ItemsView>
</nav>

See https://github.com/rappid/rappidjs.com/blob/master/public/app/IndexClass.js for the implementation of isPageSelected . 有关isPageSelected的实现,请参见https://github.com/rappid/rappidjs.com/blob/master/public/app/IndexClass.js

For a reusable solution, you could a menu component that gets the ModuleLoader as attribute and dynamically get all registered modules from the moduleLoader.$modules array. 对于可重用的解决方案,您可以使用一个菜单组件,该组件将ModuleLoader作为属性,并从moduleLoader.$modules数组动态获取所有已注册的模块。

We haven't built such a component, because a menu can contain more items than the registered ones in the ModuleLoader. 我们没有构建这样的组件,因为菜单所包含的项目比ModuleLoader中注册的项目更多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用AngularJS中的相同控制器在视图之间共享变量? - How can i share variables between views, with the same controller in AngularJS? 如何在Aurelia的两个视图之间传递数据? - How can I pass data between two views in Aurelia? 如何在angularjs中维护视图模型数据的同时在不同视图之间导航 - How can I navigate between different views while maintaining views model data in angularjs 在angularJS中的两个视图之间共享数据 - share data between two Views in angularJS 如何在JS中的部分视图之间共享信息 - How to share information between partial views in JS 如何使用postMessage在顶级窗口之间共享数据? - How can I use postMessage to share data between top level windows? 如何在Node中的2个文件之间共享模块专用数据? - How can I share module-private data between 2 files in Node? 我如何在两个之间共享数据 <ons-template> ?使用angularjs和onsen ui - how can I share data between two <ons-template> ?use angularjs and onsen ui 在这种情况下,我可以在兄弟组件之间共享数据吗? - Can I share data between sibling components in this case? 如何将数据发送给将在网页浏览之间保留但不会重新发送到服务器的用户? - How can I send data to a user that will persist between web page views, but which won't be resent to the server?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM