-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinitTestApp.js
More file actions
98 lines (75 loc) · 2.54 KB
/
initTestApp.js
File metadata and controls
98 lines (75 loc) · 2.54 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
var app = angular.module('testApp', ['ngRoute'])
app.config(
function ($controllerProvider, $provide, $compileProvider, $routeProvider) {
// Since the "shorthand" methods for component
// definitions are no longer valid, we can just
// override them to use the providers for post-
// bootstrap loading.
console.log("Config method executed.");
// Let's keep the older references.
app._controller = app.controller;
app._service = app.service;
app._factory = app.factory;
app._value = app.value;
app._directive = app.directive;
// Provider-based controller.
app.controller = function (name, constructor) {
$controllerProvider.register(name, constructor);
return( this );
};
// Provider-based service.
app.service = function (name, constructor) {
$provide.service(name, constructor);
return( this );
};
// Provider-based factory.
app.factory = function (name, factory) {
$provide.factory(name, factory);
return( this );
};
// Provider-based value.
app.value = function (name, value) {
$provide.value(name, value);
return( this );
};
// Provider-based directive.
app.directive = function (name, factory) {
$compileProvider.directive(name, factory);
return( this );
};
// NOTE: You can do the same thing with the "filter"
// and the "$filterProvider"; but, I don't really use
// custom filters.
$routeProvider
.when('/', {
templateUrl: 'templates/loginWithFacebook.html'
})
.when('/accessToken', {
templateUrl: 'templates/subView1.html'
})
.when('/name', {
templateUrl: 'templates/subView2.html'
})
.otherwise({redirectTo: '/'});
}
);
var initTestApp = function (accessToken) {
app.value('accessToken', accessToken);
app.value('name', 'Demitri Nava')
app.factory('simpleFactory', ['accessToken', 'name', function (accessToken, name) {
var accessToken = accessToken
var name = name;
var service = {};
service.accessToken = function () {
return accessToken
};
service.name = function () {
return name;
};
return service
}]);
app.controller('testController', function ($scope, simpleFactory) {
$scope.service = simpleFactory;
});
window.location = '#/accessToken';
};