notes-create-controller.js 553 B

123456789101112131415161718192021222324
  1. angular.module("noteWrangler")
  2. .controller("NoteCreateController", function ($scope, Note) {
  3. $scope.note = new Note();
  4. $scope.saveNote = function (note) {
  5. $scope.errors = null;
  6. $scope.updating = true;
  7. note.$save(note)
  8. .catch(function (note) {
  9. $scope.errors = [note.data.error];
  10. })
  11. .finally(function () {
  12. $scope.updating = false;
  13. });
  14. };
  15. });
  16. /* Somewhere in templates, to show the error:
  17. <p ng-if="createController.errors">
  18. {{ createController.errors }}
  19. </p>
  20. */