-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy path_app.js
More file actions
57 lines (47 loc) · 1.18 KB
/
_app.js
File metadata and controls
57 lines (47 loc) · 1.18 KB
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
48
49
50
51
52
53
54
55
56
57
window.applicationContextPath = window.applicationContextPath || "";
var mocks = parent.parent ? parent.parent.mocks : parent.mocks;
mocks = mocks || [];
var dependencies = mocks.concat(["ngResource"]);
var app = angular.module("TodoApp", dependencies);
if (undefined != mocks.initializeMocks) {
app.run(mocks.initializeMocks);
}
app.controller("TodoCtrl", function ($scope, NoteDAO)
{
var EDIT_MODE = "edit";
var mode;
function refresh()
{
NoteDAO.query(function (data)
{
$scope.notes = data;
});
}
$scope.isEditNoteMode = function ()
{
return EDIT_MODE === mode;
};
$scope.addNote = function ()
{
$scope.selectedNote = {};
mode = EDIT_MODE;
};
$scope.cancel = function ()
{
mode = undefined;
};
$scope.save = function ()
{
NoteDAO.save($scope.selectedNote, refresh);
mode = undefined;
};
$scope.remove = function (note)
{
NoteDAO.remove({id: note.id}, null, refresh);
};
refresh();
});
app.factory("NoteDAO", function ($resource)
{
return $resource(window.applicationContextPath + "/rest/note/:id", {id: "@id"});
});