javascriptcordovasteroidssupersonicappgyver

Get some values in opener Page from the Modal onHide, using Supersonic/Steroids


I´m starting using Supersonic/Steroids. I have a page.html, that opens a Modal Page using

<super-modal-show location=“modal.html”>click me</super-modal-show>

and I need, when the Modal is closed, to return some values and get those values in the opener Page.

Any ideas how can I do this?

Thanks in advance.


Solution

  • There are a few ways to do something like this.

    You can checkout the Superscope option here: Supersonic Superscope This way you can bind data across views. From the docs:

    // In your main view controller
    angular
        .module('first')
        .controller('FirstController', function($scope, supersonic) {
            // initialize the variable in local scope
            $scope.message = null;
    
            // bind it to superscope
            supersonic.bind($scope, "message");
    });
    
    // And in your modal view controller
    
    angular
        .module('second')
        .controller('SecondController', function($scope, supersonic) {
            $scope.message = null;
            supersonic.bind($scope, "message");
    });
    

    There is also messaging which you can publish across channels and subscribe to the channels in different controllers. Publish Across Channels

    There is also localStorage if you are more comfortable with that. I'd recommend namespacing your localStorage objects in case other applications on the phone use the same object name since it would be shared.

    Check out that documentation and you will find multiple ways to accomplish what you need.