Skip to content

Commit 9d41118

Browse files
committed
update example with $http on the server
1 parent f74510e commit 9d41118

File tree

9 files changed

+85
-60
lines changed

9 files changed

+85
-60
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
.meteor/local
2-
packages/
32
.idea

.meteor/.finished-upgraders

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
notices-for-0.9.0
66
notices-for-0.9.1
77
0.9.4-platform-file
8+
notices-for-facebook-graph-api-2

.meteor/release

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
METEOR@1.0
1+
METEOR@1.1.0.2

.meteor/versions

+51-52
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,51 @@
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-
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+
netanelgilad:[email protected]_1
33+
34+
35+
36+
37+
38+
39+
40+
41+
42+
43+
44+
45+
46+
47+
48+
49+
50+
51+

client/controllers/main.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
22
* Created by netanel on 27/02/15.
33
*/
4-
angular.module('todos').controller('MainController', function($scope, Todos, $meteorCollection, TodosManager) {
5-
$scope.todos = $meteorCollection(Todos.collection).subscribe('todos');
4+
angular.module('todos').controller('MainController', function($scope, Todos, $meteorCollection, TodosManager, Data) {
5+
$scope.todos = $meteorCollection(Todos.collection, false).subscribe('todos');
66

77
$scope.newTask = {
88
text : '1'
@@ -12,4 +12,13 @@ angular.module('todos').controller('MainController', function($scope, Todos, $me
1212
TodosManager.addTodo($scope.newTask);
1313
$scope.newTask = {};
1414
};
15+
16+
$scope.doCoolThing = function() {
17+
Data.getData().then(function(response) {
18+
$scope.response = response;
19+
}, function(error) {
20+
$scope.response = 'Error:' + error;
21+
console.log(error);
22+
});
23+
}
1524
});

client/partials/index.ng.html

+4
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@ <h1>Tasks</h1>
99
Text: <input type="text" ng-model="newTask.text" />
1010
<button ng-click="addTodo(newTask)">Add Task</button>
1111
</div>
12+
<div>
13+
<button ng-click="doCoolThing()">Do cool thing</button>
14+
Response : {{ response }}
15+
</div>
1216
</div>

lib/app.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@
44
angular.module('todos', ['angular-meteor']);
55

66
if (Meteor.isServer) {
7-
Meteor.startup(function() {
8-
angular.bootstrap(['todos']);
9-
});
7+
angular.bootstrap(['todos']);
108
}

server/data.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
angular.module('todos').config(function(ServerAPIProvider) {
2+
ServerAPIProvider.register('Data');
3+
});
4+
5+
angular.module('todos').service('Data', function($http) {
6+
this.getData = function () {
7+
return $http.get('https://www.facebook.com/');
8+
};
9+
});

server/todos.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
/**
22
* Created by netanel on 27/02/15.
33
*/
4+
45
angular.module('todos')
5-
.service('TodosManager', function (Todos) {
6+
.service('TodosManager', function (Todos, $http, $document) {
67
this.addTodo = function (todo) {
78
if (todo.text.length < 3) {
89
console.log('Error trying to add a todo with less than 3 letters ', todo.text);
@@ -12,6 +13,11 @@ angular.module('todos')
1213
}
1314
};
1415

16+
this.callServer = function() {
17+
console.log($document);
18+
return $http.get('http://requestb.in/1divtht1');
19+
};
20+
1521
Meteor.publish('todos', function () {
1622
return Todos.collection.find({});
1723
});

0 commit comments

Comments
 (0)