addBook.controller.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. (function(){
  2. 'use strict';
  3. app.controller('AddBook', addBookController);
  4. function addBookController($scope, $uibModalInstance, booksRepository){
  5. $scope.newBook = {
  6. title: '',
  7. author_id: null,
  8. date: "",
  9. cost: '',
  10. rate: '',
  11. intro: ''
  12. }
  13. booksRepository.getAuthors()
  14. .then(function(response){
  15. $scope.authors = response.data.map(function(author){
  16. return {
  17. id: author.id,
  18. name: author.firstname + ' ' + author.lastname
  19. }
  20. })
  21. });
  22. $scope.cancel = function(){
  23. $uibModalInstance.dismiss('cancel');
  24. // $uibModalInstance.close(false);
  25. };
  26. $scope.ok = function(){
  27. $uibModalInstance.close($scope.newBook);
  28. }
  29. }
  30. addBookController.$inject = [
  31. '$scope',
  32. '$uibModalInstance',
  33. 'books.repository',
  34. '$uibModalInstance'
  35. ];
  36. })()