Modified examples from ng-book, a great introduction to angular.js