2015-04-23 28 views
0

我想要使用AngularUI模态的,我似乎无法弄清楚为什么它不解决我的变量。打开模态和模态实例模态实例不解析输入

$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() {}); 
}; 

模态控制器的一些东西在这里

功能是吃剩的调试从

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(); 
    }; 
}]); 

的主要问题是,当它进入控制器我得到了未定义的证书,即使它应该由openModal函数解决。我下面就如何在这里做他们的官方角度UI教程:Angular UI Bootstrap Modals

+0

这个计算器的回答可以帮助你,我觉得 http://stackoverflow.com/questions/29768946/how-to-open-a-ui-bootstrap-modal-from -an-angularjs-controller-and-capture-select – RK6

+0

谢谢,但我无法找到我在那里找的东西。 – electrometro

回答

1

在你的“证书”到控制器中的注射,你需要把它添加到名称声明以及功能。

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