how to pass parameters to modal popup?

 ̄綄美尐妖づ 提交于 2020-01-05 04:01:06

问题


I am working on Nativescript application where i need to open view on click of list item. So i will have to pass id of that item to the modal that is about to open on click of list item.

Here is my code as i tried and for opening modal popup :

var modalPageModule = views.appointmentDetails;
var context = {
  id: args.view.bookingId // i tried this way for passing parameter
};
var fullscreen = true;
page.showModal(modalPageModule, context, function closeCallback(parameters) {
 // Log the user in...

}, fullscreen);

And code for getting passed parameter on controller of modal popup

page = args.object;
var gotData = page.navigationContext;
var id = gotData.id;

But returns NaN.

Please suggest some way to pass variable to modal popup.


回答1:


Problem solved after making change in XML file

<Page xmlns="http://schemas.nativescript.org/tns.xsd"
      xmlns:widgets="utils/widgets"
      showingModally="onLoaded">

and in modal controller

exports.onLoaded = function(args) {
    var id = args.context.id


来源:https://stackoverflow.com/questions/39050898/how-to-pass-parameters-to-modal-popup

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