javascript - Angular js 中未定义 modalInstance

标签 javascript angularjs bootstrap-modal

ModalInstance 数据在导入 Controller 时变为 NULL。 我也更改了 modelInstance 名称。但没有成功。 这里添加我的代码,

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

请帮忙

最佳答案

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

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

关于javascript - Angular js 中未定义 modalInstance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46660636/

相关文章:

javascript - Protractor 重复规范

javascript - 如何在我的 ember View 中绑定(bind)到 bootstrap 的模态事件?

javascript - Three.js 的第一个示例不起作用

javascript - 为什么我的组件绑定(bind)在其 Controller 中未定义?

javascript - 未捕获的类型错误 : Cannot read property 'sheet' of null

php - MYSQL 在模态中选择 ID

css - Bootstrap navBar 重叠模态淡入淡出

javascript - 所选元素具有相同的值但不同的 id

javascript - 如何在不知道 key 的情况下获取JSON对象的第一个 key 对元素并在节点红色中将其删除

javascript - jQuery - .animate 之后的链接