I'm using angular UI modal, in the template of my modal I have 2 inputs and a button, this are using th ng-model attribute, ok, I have a controller set for the modal, which works, it does everything but getting the values of the inputs even when I set a value in the controller for the input it changes it, but when I try to get the value from the template I got an undefined response, I make this plunker and kinda insert my modal and made a controller for it one button sets a predefined value in the input and the other one tries to get it , I hope somebody could help me, thx
1 Answer
The modal window has its own scope. What you'll want to do is take your model and make it an object. So take bootusername and name it something like bootusername.text
You can then initialize bootusername in the instance controller and set the model like so:
var ModalInstanceCtrl = function ($scope, $modalInstance) { $scope.bootusername = {}; //initialize the object $scope.check1 = function() { $scope.bootusername.text = 56; //set the object here or just type in input }; $scope.check2 = function() { console.log($scope.bootusername.text); }; $scope.ok = function() { $modalInstance.close($scope.selected.item); }; $scope.cancel = function() { $modalInstance.dismiss('cancel'); }; };