/
sandbox.ts
78 lines (58 loc) · 2.06 KB
/
sandbox.ts
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
///<reference path="../../../../src/global.d.ts" />
namespace app.guest.sandbox {
export const namespace = 'app.guest.sandbox';
class SandboxConfig {
static $inject = ['stateHelperServiceProvider'];
constructor(private stateHelperServiceProvider){
let state:global.IState = {
url: '/sandbox',
views: {
"main@app.guest": {
controller: namespace+'.controller',
templateUrl: 'templates/app/guest/sandbox/sandbox.tpl.html'
}
},
resolve: /*@ngInject*/{
},
data: {
title: "Sandbox",
role: 'public',
icon: 'extension',
navigation: true,
sortAfter: app.guest.articles.namespace,
}
};
stateHelperServiceProvider.addState(namespace, state);
}
}
interface IScope extends ng.IScope
{
callApi(apiEndpoint:string):void;
promptLogin():void;
apiResult: any;
}
class SandboxController {
static $inject = ['$scope', 'ngRestAdapter', 'ngJwtAuthService', '$window'];
constructor(
private $scope : IScope,
private ngRestAdapter:NgRestAdapter.NgRestAdapterService,
private ngJwtAuthService:NgJwtAuth.NgJwtAuthService,
private $window:ng.IWindowService
) {
$scope.callApi = _.bind(this.callApi, this); //bind method to scope
//$scope.promptLogin = () => ngJwtAuthService.promptLogin();
}
public callApi(apiEndpoint):void {
this.ngRestAdapter
.api('/api-mock')
.get(apiEndpoint)
.then((result) => {
this.$scope.apiResult = result;
})
;
}
}
angular.module(namespace, [])
.config(SandboxConfig)
.controller(namespace+'.controller', SandboxController);
}