modalInstance在Angular js中未定义

时间:2017-10-10 07:13:30

标签: javascript angularjs bootstrap-modal

ModalInstance数据在导入控制器时变为NULL。 我也改变了modelInstance名称。但是dint工作了。 这里正在添加我的代码,

SaveController.js

scope.open = function (_data) {   //data is present 
    var modalInstanceData = modal.open({
      controller: "PopUpController",
      templateUrl: 'myModalContent.html',
        resolve: {
            data: function()
            {
                return _data; // values are present here
            }
            }
         });

};

PopUpController.js

angular.module('user').controller('PopUpController',
    ['$scope','$state','$uibModalInstance',
     function(scope,state,modalInstanceData,data) {

        data={};
        scope.data = data;   
        farmBid.produceValue = scope.data.produceId; //value is present here

    }])

HTML

<script type="text/ng-template" id="myModalContent.html">

                <div class="modal-body">
   <input type="text" name="produceValue" ng-model="farmBid.produceValue" />

   <!-- But here its not prefilling the data-->

   <input type="submit" ng-click="generate(farmBid)">
                </div>
 </script>

   Modal data values are not being visible in HTML page

请帮忙

1 个答案:

答案 0 :(得分:1)

您应该按照正确的顺序传递参数并且应该匹配,您缺少 'data'

angular.module('user').controller('PopUpController',
    ['$scope','$state','$uibModalInstance','data',
     function(scope,state,modalInstanceData,data) {