I am having difficulties with referencing the scope in an angular-ui modal. Whenever I try to access the value of the scope, I receive an undefined message. My goal is to retrieve the data entered into ng-model="input.cost_center". Despite trying examples from others on the same topic, it doesn't seem to be working for me. Can anyone provide assistance? Thank you in advance.
Here is the plunk http://plnkr.co/edit/tIh5rbvseD7vxfPJHFd6?p=preview
Modal
$scope.openAddCenter = function () {
var modalAddCenter = $modal.open({
templateUrl: 'myModalAddCenter.html',
controller: ModalAddCenterCtrl,
resolve: {
'$modalAddCenter': function() {
return function() {
return modalAddCenter; }
}
}
});
};
Modal Controller
var ModalAddCenterCtrl = function ($scope, $modalAddCenter, $http){
$scope.input = {};
$scope.ok = function(){
alert($scope.input.cost_center);
$modalAddCenter().close();
};
$scope.cancel = function(){
$modalAddCenter().dismiss('cancel');
};
};
HTML
<input type="text" class="form-control" id="modalCenter" ng-model="input.cost_center" placeholder="Cost Center" ng-minLength="8" maxLength="8" required />