-
Notifications
You must be signed in to change notification settings - Fork 5
/
testApp.js
61 lines (53 loc) · 1.24 KB
/
testApp.js
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
58
59
60
61
angular.module('testApp', ['js-data'])
.service('User', function (DS) {
return DS.defineResource({
name: 'user',
computed: {
fullName: {
get: function () {
return 'John Doe';
}
},
nickname: function () {
return 'Johny';
},
alternateNickname: [function () {
return 'Doey';
}],
initials: ['fullName', function (fullName) {
var names = fullName.split(' ');
var initials = names.reduce(function (initials, name){
return initials + name[0].toUpperCase();
}, '')
return initials;
}]
}
});
})
.controller('TestCtrl', function ($scope, DS, User) {
'use strict';
$scope.test = function () {
DS.findAll('post', {
where: {
author: {
'==': 'John Anderson'
}
}
});
$scope.injected = DS.inject('user', {
name: 'Sally',
id: 6
});
DS.ejectAll('post', {
where: {
author: {
'==': 'John Anderson'
}
}
});
DS.find('post', 1);
DS.find('post', 1);
User.find(4);
return DS.find('user', 5);
};
});