Hema
Hema

Reputation: 986

modalInstance is undefined in Angular js

ModalInstance data is getting NULL in importing controller. I have changed modelInstance name also.But dint work out. here am adding my code,

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

Please help

Upvotes: 0

Views: 419

Answers (1)

Sajeetharan
Sajeetharan

Reputation: 222522

You should pass the parameters in right order and should match, you are missing 'data'

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

Upvotes: 1

Related Questions