notes-edit-controller.js 722 B

123456789101112131415161718192021
  1. angular.module('noteWrangler')
  2. .controller("NotesEditController", ['$scope', '$routeParams', 'Note', function ($scope, $routeParams, Note) {
  3. $scope.note = Note.get({ id: $routeParams.id });
  4. $scope.updateNote = function (noteObj) {
  5. $scope.errors = null;
  6. $scope.updating = true;
  7. // NB: we declared "update", but call "$update".
  8. Note.$update(noteObj)
  9. .catch(function (note) {
  10. $scope.errors = [note.data.error];
  11. })
  12. .finally(function () {
  13. $scope.updating = false;
  14. });
  15. };
  16. $scope.deleteNode = function(note) {
  17. // $remove is the same, but avoids problems with delete being reserved in IE.
  18. Note.$delete(note);
  19. };
  20. }]);