ModalInstance数据在导入控制器中变为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/

10-12 02:24