/app/public/js/libs/angular/docs/partials/api/angular.module.html
HTML | 54 lines | 46 code | 8 blank | 0 comment | 0 complexity | efdc98032c65b9b38cc77241a8be8f65 MD5 | raw file
1<h1><code ng:non-bindable="">angular.module</code>
2<span class="hint">(API in module <code ng:non-bindable="">ng</code>
3)</span>
4</h1>
5<div><h2 id="Description">Description</h2>
6<div class="description"><p>The <code>angular.module</code> is a global place for creating and registering Angular modules. All
7modules (angular core or 3rd party) that should be available to an application must be
8registered using this mechanism.</p>
9
10<h3>Module</h3>
11
12<p>A module is a collocation of services, directives, filters, and configure information. Module
13is used to configure the <a href="api/AUTO.$injector"><code>$injector</code></a>.</p>
14
15<pre class="prettyprint linenums">
16// Create a new module
17var myModule = angular.module('myModule', []);
18
19// register a new service
20myModule.value('appName', 'MyCoolApp');
21
22// configure existing services inside initialization blocks.
23myModule.config(function($locationProvider) {
24 // Configure existing providers
25 $locationProvider.hashPrefix('!');
26});
27</pre>
28
29<p>Then you can create an injector and load your modules like this:</p>
30
31<pre class="prettyprint linenums">
32var injector = angular.injector(['ng', 'MyModule'])
33</pre>
34
35<p>However it's more likely that you'll just use
36<a href="api/ng.directive:ngApp"><code>ngApp</code></a> or
37<a href="api/angular.bootstrap"><code>angular.bootstrap</code></a> to simplify this process for you.</p></div>
38<h2 id="Usage">Usage</h2>
39<div class="usage"><pre class="prettyprint linenums">angular.module(name[, requires], configFn);</pre>
40<h3 id="Parameters">Parameters</h3>
41<ul class="parameters"><li><code ng:non-bindable="">name � {!string} � </code>
42<p>The name of the module to create or retrieve.</p></li>
43<li><code ng:non-bindable="">requires<i>(optional)</i> � {Array.<string>=} � </code>
44<p>If specified then new module is being created. If unspecified then the
45the module is being retrieved for further configuration.</p></li>
46<li><code ng:non-bindable="">configFn � {Function} � </code>
47<p>Option configuration function for the module. Same as
48<a href="api/angular.Module#config"><code>Module#config()</code></a>.</p></li>
49</ul>
50<h3 id="Returns">Returns</h3>
51<div class="returns"><code ng:non-bindable="">{module}</code>
52� <p>new module with the <a href="api/angular.Module"><code>angular.Module</code></a> api.</p></div>
53</div>
54</div>