I need to get the object that is sent to my controller in a modal.
When I click on the option to display the modal, I access a function from my controller:
$scope.enable= function(user, callback) {
//Verifico se o objeto está chegando no controller
console.log(user);
var modalInstance = $modal.open({
templateUrl: 'app/views/liberacao.html',
controller: 'UserController',
size: 'sm',
resolve: {
user: function() {
return user;
}
}
});
modalInstance.result.then(function(user) {
if (callback) {
callback(user);
}
});
};
I send the object to my controller, where I indicate the modal definitions and in the resolve parameter, I return the loaded object. However, when opening the modal the object is not loaded.
Modal html:
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
Liberar {{user.name}} até
<div class="input-group">
<input type="text" class="form-control" datepicker-popup="dd/MM/yyyy" ng-model="user.extraDate" is-open="openedInicial" current-text="Hoje" clear-text="Limpar" close-text="Fechar" required />
<div class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="openDatePicker($event)"><i class="glyphicon glyphicon-calendar"></i></button>
</div>
</div>
</div>
<div class="modal-body">
<div class="btn-group-action">
<button ng-click="" type="button" class="btn btn-success btn-lg btn-block btn-confirm-delete">Salvar</button>
</div>
</div>