Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular ui bootstrap modal passing multiple parameters

I am using an angular ui bootstrap modal for one of my applications. Currently i am calling the modal instance using the following:

<button class="btn btn-default btn-sm pull-right" 
ng-click="open({{node.id}})">Add Course <span class="glyphicon glyphicon-plus">
</span>
</button>

I have defined the modal as follows:

$scope.open = function (node) {
    var modalInstance = $modal.open({
        templateUrl: 'myModalContent.html',
        controller: ModalInstanceCtrl,
        resolve: {
            detail: function() {
                return node;
            }
        }   
    });
};

Here the open() function passes the id of the node. Here node is a django item which has details like id, required etc..

My modal instance is defined as follows:

var ModalInstanceCtrl = function ($scope, $http, $log, $modalInstance, detail) {
    $scope.subcategory = detail;
};

So far the modal works fine and i am able to pass the node.id to the modal. But now i want to pass even the other parameters within the node like open({{node.required}}, {{node.id}}) etc to the modal. How do i modify my modal open() and modalinstance() functions to receive multiplt parameters?

like image 420
Abhishek Avatar asked Dec 01 '22 01:12

Abhishek


1 Answers

You can add more objects to the resolve section:

$scope.open = function (node, node2) {
    var modalInstance = $modal.open({
        templateUrl: 'myModalContent.html',
        controller: ModalInstanceCtrl,
        resolve: {
            detail: function() {
                return node;
            },
            detail2: function() {
                return node2;
            }
        }   
    });
};
like image 89
mer10z_tech Avatar answered Dec 04 '22 01:12

mer10z_tech