0

I am trying to use AngularUI modal's and I cannot seem to figure out why it is not resolving my variables.

Function that opens the modal and the modal instance

$scope.openModal = function (size, cert) {

    var modalInstance = $modal.open({
        template: 'ModalContent.html',
        controller: 'ModalInstanceCtrl',
        size: size,
        resolve: {
            certs: function () {
                return $scope.certification;
            }
        }
   });

   modalInstance.result.then(function () {});
};

Modal Controller some stuff in here is leftover from debugging

angular.module('myApp').controller('ModalInstanceCtrl', ['$scope', '$filter', '$modalInstance', function ($scope, $filter, $modalInstance, certs) {

     console.log(certs);

     var results = $filter('filter')(certs, {id: id})[0];

     $scope.cert = results;

     $scope.ok = function () {
        $modalInstance.close();
    };
}]);

The main issue is that when it gets into the controller I am getting undefined for certs even though it should be resolved by the openModal function. I was following the official angular UI tutorial on how to do them here: Angular UI Bootstrap Modals

2
  • This stackoverflow answer might help you, i think stackoverflow.com/questions/29768946/… Commented Apr 23, 2015 at 7:03
  • Thanks but I wasn't able to find what I was looking for in there. Commented Apr 23, 2015 at 15:07

1 Answer 1

1

In your injection of 'certs' into your controller, you need to add it to the name declaration as well as the function.

angular.module('myApp').controller('ModalInstanceCtrl', ['$scope', '$filter', '$modalInstance', 'certs', function ($scope, $filter, $modalInstance, certs) {

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.