简体   繁体   English

使用Iron-ajax在Polymer Elements之间发送数据

[英]Send data between Polymer Elements using iron-ajax

I'm having the my-app.html which does have the app-toolbar, app-drawerlayout and etc which is loading the my menu elements( myView1.html and myView2.html ). 我有my-app.html ,它确实具有app-toolbar,app-drawerlayout等,正在加载我的菜单元素( myView1.htmlmyView2.html )。

I have iron-ajax call in myView1.html so when the response comes in the myView1.html it should navigate to myView2.html with response data came from the iron-ajax call 我在myView1.html中有iron-ajax调用,所以当响应进入myView1.html时,它应该导航到myView2.html,并且响应数据来自iron-ajax调用

 // Function called when the response comes from iron-ajax
 function navigateToView2(data) {
        window.href = "/myView2";
 }

Please Help me, thanks in Advance 请帮助我,提前谢谢

If you are doing a SPA (Single Page Application) and using the app-route element you will need to fire your own event from myView1.html to the my-app.html that contains the results of your ajax call. 如果您正在执行SPA(单页应用程序)并使用app-route元素,则需要将自己的事件从myView1.html触发到包含ajax调用结果的my-app.html。 Then have the my-app.html change the app-route path to myView2.html. 然后让my-app.html将应用程序路由路径更改为myView2.html。 All while using data-binding to send the ajax response to the myView2.html. 始终使用数据绑定将ajax响应发送到myView2.html。 Events Up / Data Down! 事件增加/数据减少! When using app-route the my-app.html file should control the changing of the SPA pages especially if you are needing to make sure to perform some kind of data-binding before loading the new page. 使用app-route时,my-app.html文件应控制SPA页面的更改,尤其是在需要确保在加载新页面之前执行某种数据绑定的情况下。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM