PopPage with returning parameters with Onsen UI

耗尽温柔 提交于 2019-12-07 11:03:46

问题


I have two pages: page1.html has a button that opens page2.html with pushPage('page2.html'). Then I would like to have a selectable parameter (I'm using radio buttons) to be returned to page1.html, so I use $scope.appNavigator.popPage({myParam: myValue}), but at the controller of page1.html there're no params. I expected to find myParam with:

var page = $scope.accidentInvestigationNavigator.getCurrentPage();
$scope.myParam = page.options.myParam;

Is it possible to send parameters to the previous page with popPage()?... if not, how could I return with a parameter?


回答1:


pushPage creates a new page object with the custom options but popPage doesn't create nor overwrite anything, so you cannot pass custom options backwards. This is not a bug, it is just designed like that right now.

There are many ways to share information between controllers in AngularJS: services, parent controllers, event broadcast...

I have made an example with 3 different approaches here: http://codepen.io/frankdiox/pen/XbvzKJ

I think the most interesting way is to use Onsen's prepop event to share information when you do a popPage.

Hope it helps!



来源:https://stackoverflow.com/questions/32187423/poppage-with-returning-parameters-with-onsen-ui

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!