@ngdoc overview @name angular.module @description The angular.module namespace is a global place for registering angular modules. All modules (angular core or 3rd party) that should be available to an application must be registered in this namespace. # Module A module is a function that is used to register new service providers and configure existing providers. Once a provider is registered, {@link angular.module.AUTO.$injector $injector} will use it to ask for a service instance when it is resolving a dependency for the first time.
// Declare the module configuration function.
// The function arguments are fully injectable so that the module function
// can create new providers or configure existing ones.
function MyModule($provide, $locationProvider){
  // see $provide for more information.
  $provide.value('appName', 'MyCoolApp');

  // Configure existing providers
  $locationProvider.hashPrefix = '!';
};
See: {@link angular.module.NG.$provide $provide}, {@link angular.module.NG.$locationProvider $locationProvider}. # Registering Module Function In your JavaScript file:
// Create the angular.module namespace if one does not exist
// This allows the module code to be loaded before angular.js code.
if (!window.angular) window.angular = {};
if (!angular.module) angular.module = {};

angular.module.MyModule = function(){
  // add configuration code here.
};
Then you can refer to your module like this:
var injector = angular.injector('NG', 'MyModule')
Or
var injector = angular.injector('NG', angular.module.MyModule)
rk/angular.js/tree/docs/src/example.js?h=v1.0.7&id=0d8e19c26f941004b0472fe56b2601dc86887668'>treecommitdiffstats
path: root/docs/src/example.js
blob: 7477b0a5055cbef8328b7dd088b2158a7810d0cc (plain)
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126