|
1 | 1 | 'use strict'; |
| 2 | + |
2 | 3 | (function() { |
3 | 4 |
|
4 | | -function MainController($scope, $http<% if (filters.socketio) { %>, socket<% } %>) { |
5 | | - var self = this; |
6 | | - this.awesomeThings = []; |
7 | | - |
8 | | - $http.get('/api/things').then(function(response) { |
9 | | - self.awesomeThings = response.data;<% if (filters.socketio) { %> |
10 | | - socket.syncUpdates('thing', self.awesomeThings);<% } %> |
11 | | - }); |
12 | | -<% if (filters.models) { %> |
13 | | - this.addThing = function() { |
14 | | - if (self.newThing === '') { |
15 | | - return; |
16 | | - } |
17 | | - $http.post('/api/things', { name: self.newThing }); |
18 | | - self.newThing = ''; |
19 | | - }; |
20 | | - |
21 | | - this.deleteThing = function(thing) { |
22 | | - $http.delete('/api/things/' + thing._id); |
23 | | - };<% } %><% if (filters.socketio) { %> |
24 | | - |
25 | | - $scope.$on('$destroy', function() { |
26 | | - socket.unsyncUpdates('thing'); |
27 | | - });<% } %> |
28 | | -} |
29 | | - |
30 | | -angular.module('<%= scriptAppName %>') |
31 | | - .controller('MainController', MainController); |
| 5 | + function MainController($scope, $http<% if (filters.socketio) { %>, socket<% } %>) { |
| 6 | + var self = this; |
| 7 | + this.awesomeThings = []; |
| 8 | + |
| 9 | + $http.get('/api/things').then(function(response) { |
| 10 | + self.awesomeThings = response.data;<% if (filters.socketio) { %> |
| 11 | + socket.syncUpdates('thing', self.awesomeThings);<% } %> |
| 12 | + });<% if (filters.models) { %> |
| 13 | + |
| 14 | + this.addThing = function() { |
| 15 | + if (self.newThing === '') { |
| 16 | + return; |
| 17 | + } |
| 18 | + $http.post('/api/things', { name: self.newThing }); |
| 19 | + self.newThing = ''; |
| 20 | + }; |
| 21 | + |
| 22 | + this.deleteThing = function(thing) { |
| 23 | + $http.delete('/api/things/' + thing._id); |
| 24 | + };<% } if (filters.socketio) { %> |
| 25 | + |
| 26 | + $scope.$on('$destroy', function() { |
| 27 | + socket.unsyncUpdates('thing'); |
| 28 | + });<% } %> |
| 29 | + } |
| 30 | + |
| 31 | + angular.module('<%= scriptAppName %>') |
| 32 | + .controller('MainController', MainController); |
32 | 33 |
|
33 | 34 | })(); |
0 commit comments