code following ProAngularJS/Adam Freeman/Apress