Created
February 26, 2016 17:49
-
-
Save adamburvill/1e375062ef84cac65848 to your computer and use it in GitHub Desktop.
Basic angular controller making use of the Book service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
// @ngInject | |
function BookCtrl(Book){ | |
var vm = this; | |
vm.error = ''; | |
vm.books = []; | |
vm.getAllBooks = function() { | |
Book.query() | |
.then(function(success) { | |
vm.books = success; | |
}) | |
.catch(function(error) { | |
vm.error = 'Unknown error'; | |
}) | |
} | |
} | |
angular | |
.module('app') | |
.controller('BookCtrl', BookCtrl); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment