@@ -7,8 +7,15 @@ import uiRouter from 'angular-ui-router';<% } _%>
7
7
import routing from './main.routes';
8
8
9
9
export class MainController {
10
+ < % _ if ( filters . ts ) { _ % >
11
+ $http : ng . IHttpService ;
12
+ socket ;
13
+ awesomeThings : IThing [ ] ;
14
+ newThing : string ;
15
+ < % _ } _ % >
16
+
10
17
/*@ngInject */
11
- constructor ( $http < % if ( filters . socketio ) { % > , $scope , socket < % } % > ) {
18
+ constructor ( $http < % _ if ( filters . ts ) { _ % > : ng . IHttpService < % _ } _% > < % if ( filters . socketio ) { % > , $scope< % _ if ( filters . ts ) { _ % > : ng.IScope < % _ } _ % > , socket< % } % > ) {
12
19
this . $http = $http ; < % if ( filters . socketio ) { % >
13
20
this . socket = socket ; < % } %>
14
21
this . awesomeThings = [ ] ;
@@ -21,7 +28,7 @@ export class MainController {
21
28
22
29
$onInit ( ) {
23
30
this . $http . get ( '/api/things' ) . then ( response => {
24
- this . awesomeThings = response . data ; < % if ( filters . socketio ) { % >
31
+ this . awesomeThings = < % if ( filters . ts ) { % > < IThing [ ] > < % } % > response.data;< % if ( filters . socketio ) { % >
25
32
this . socket . syncUpdates ( 'thing' , this . awesomeThings ) ; < % } % >
26
33
} ) ;
27
34
} < % if ( filters . models ) { % >
@@ -33,11 +40,18 @@ export class MainController {
33
40
}
34
41
}
35
42
36
- deleteThing ( thing ) {
43
+ deleteThing ( thing < % _ if ( filters . ts ) { _ % > : IThing < % _ } _ % > ) {
37
44
this . $http . delete ( '/api/things/' + thing . _id ) ;
38
45
} < % } % >
39
46
}
40
47
48
+ < % _ if ( filters . ts ) { _ % >
49
+ interface IThing {
50
+ _id : string ;
51
+ name : string ;
52
+ info : string ;
53
+ } < % } _ % >
54
+
41
55
export default angular . module ( '<%= scriptAppName %>.main' , [
42
56
< % _ if ( filters . ngroute ) { _ % >
43
57
ngRoute < % } _ % >
0 commit comments