Search code examples
angularjsui.bootstrap

Push and pull data into ui.bootstrap modal


I have set up a plunkr here: http://plnkr.co/edit/NdHqQJ?p=preview

I'm trying to push and pull the form data into the modal window when you click on the task. I have read that you can do this with the "resolve" property (seen below) of the modal but I have been unable to get it to actually work. Any insight would be greatly appreciated.

var modalInstance = $modal.open({
  templateUrl: 'editTask.html',
  controller: 'ModalInstanceCtrl',
  size: size,
  scope: $scope,
  resolve: {
    items: function () {
      return $scope.items;
    }
  }
});

Please let me know if you need more details!


Solution

  • If you want to use resolve (you can) the nit will be like this for example:

    $scope.open = function(size, task) {
        var modalInstance = $modal.open({
            templateUrl: 'editTask.html',
            controller: 'ModalInstanceCtrl',
            size: size,
            resolve: {
                task: function() {
                    return task
                }
            }
        });
    };
    

    HTML:

    <a ng-click="open('lg', noStoneTask)" style="cursor:pointer" tooltip-placement="top" tooltip="Open Task">{{noStoneTask.taskSubject}}</a>
    

    Demo: http://plnkr.co/edit/NA71479d04Yw7hh2Twx8?p=preview