Search code examples
javascriptnativescripttelerik-appbuildermodalpopup

how to pass parameters to modal popup?


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.


Solution

  • 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