0

Id like to pass data from 1 view (master view ) to modal view using angular ui bootstrap plugin , below is my code which doesn't seem to work :

master view

vm.receipt_id = "1234"

<button type="button" class="btn btn-default" ng-click="vm.alertMeJimmy(vm.receipt_id)">Large modal</button>

controller

       vm.alertMeJimmy = function(receipt_id) {

            $uibModal.open({
            animation: true ,
            templateUrl: '/cashier/views/cashier.angular_components.modal',
            controller: 'PatientsController',
            controllerAs: 'vm',
            resolve: {
             receipt_id : function () {
                  return receipt_id ;
                }

             },
            size: 'lg'

          });

        }

modal view

id like to access it like below in my modal view

<span ng-bind="vm.receipt_id " ></span>

1 Answer 1

5

Return an object instead of a primitive:

angular.module('App').controller('Controller', [
             '$uibModal',
    function ($uibModal) {
        var vm = this;
        vm.receipt_id = 1234;
        vm.alertMeJimmy = function (receipt_id) {
            var modalInstance = $uibModal.open({
                size: 'sm',
                templateUrl: 'modal.html',
                controller: 'Modal as vm',
                resolve: {
                    'receipt': { id: receipt_id }
                }
            });
        }
    }
]);

angular.module('App').controller('Modal', [
             'receipt',
    function (receipt) {
        var vm = this;
        vm.receipt = receipt;
    }
]);

Example on Plunker: http://plnkr.co/edit/d9RLJLHr1zr9d5gVKHpD?p=preview

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.