blob: bda6ae7db05fe0618e48ff37de5fc31fc88bcfe5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
angular
.module('nt.NoteService', ['ngResource'])
.factory('NoteService', [
'$resource',
function($resource) {
var Note = $resource('/notes/:id.json',
{ id: '@id' },
{
update: {
method: 'PUT'
}
});
return {
notes: [],
current_note: null,
get_notes: function() {
this.notes = Note.query();
},
get_note: function(note) {
this.current_note = note;
},
update: function() {
this.current_note.$update();
},
create: function () {
var _this = this;
if (this.new_note_title) {
Note.save({
title: this.new_note_title,
body: ''
}, function(response) {
_this.show_create = false;
delete _this.new_note_title;
_this.current_note = response;
_this.get_notes();
});
}
}
};
}
]);
|