-
Notifications
You must be signed in to change notification settings - Fork 12
/
angularBooter.js
47 lines (37 loc) · 1.4 KB
/
angularBooter.js
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
AngularBooter = function(appName) {
return {
config: [],
controllers: {},
directives: {},
dependencies: [],
filters: {},
services: {},
appName: appName ? appName : 'myApp',
boot: function() {
var thiz = this;
//Create The App Module and Inject Any Dependencies
angular.module(this.appName, this.dependencies);
console.log('Booted Dependencies', this.dependencies);
//Instantiate All Of Our Registered Services
angular.forEach(this.services, function (serviceFunction, serviceName) {
angular.module(thiz.appName).factory(serviceName, serviceFunction);
});
console.log('Booted Services', this.services);
//Instantiate our Registered Directives and Controllers
angular.module(this.appName)
.directive(this.directives)
.controller(this.controllers);
console.log('Booted Directives', this.directives);
console.log('Booted Controllers', this.controllers);
angular.forEach(this.config, function (c) {
angular.module(thiz.appName).config(c);
});
console.log('Booted Configs', this.config);
//Instantiate our Registered Filters
angular.forEach(this.filters, function (filterFunction, filterName) {
angular.module(thiz.appName).filter(filterName, filterFunction);
});
console.log('Booted Filters', this.filters);
}
};
}