(function(){ 'use strict'; app.controller('AddBook', addBookController); function addBookController($scope, $uibModalInstance, booksRepository){ $scope.newBook = { title: '', author_id: null, date: "", cost: '', rate: '', intro: '' } booksRepository.getAuthors() .then(function(response){ $scope.authors = response.data.map(function(author){ return { id: author.id, name: author.firstname + ' ' + author.lastname } }) }); $scope.cancel = function(){ $uibModalInstance.dismiss('cancel'); // $uibModalInstance.close(false); }; $scope.ok = function(){ $uibModalInstance.close($scope.newBook); } } addBookController.$inject = [ '$scope', '$uibModalInstance', 'books.repository', '$uibModalInstance' ]; })()