123456789101112131415161718192021 |
- angular.module('noteWrangler')
- .controller("NotesEditController", ['$scope', '$routeParams', 'Note', function ($scope, $routeParams, Note) {
- $scope.note = Note.get({ id: $routeParams.id });
- $scope.updateNote = function (noteObj) {
- $scope.errors = null;
- $scope.updating = true;
- // NB: we declared "update", but call "$update".
- Note.$update(noteObj)
- .catch(function (note) {
- $scope.errors = [note.data.error];
- })
- .finally(function () {
- $scope.updating = false;
- });
- };
- $scope.deleteNode = function(note) {
- // $remove is the same, but avoids problems with delete being reserved in IE.
- Note.$delete(note);
- };
- }]);
|