summaryrefslogtreecommitdiffstats
path: root/3rdparty/js/angular-1.0.2/docs/partials/api/angular.module.html
blob: a4786edec712b7c2ca6a5221ec108576e8d22563 (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
<h1><code ng:non-bindable="">angular.module</code>
<span class="hint">(API in module <code ng:non-bindable="">ng</code>
)</span>
</h1>
<div><h2 id="Description">Description</h2>
<div class="description"><p>The <code>angular.module</code> is a global place for creating and registering Angular modules. All
modules (angular core or 3rd party) that should be available to an application must be
registered using this mechanism.</p>

<h3>Module</h3>

<p>A module is a collocation of services, directives, filters, and configure information. Module
is used to configure the <a href="api/AUTO.$injector"><code>$injector</code></a>.</p>

<pre class="prettyprint linenums">
// Create a new module
var myModule = angular.module('myModule', []);

// register a new service
myModule.value('appName', 'MyCoolApp');

// configure existing services inside initialization blocks.
myModule.config(function($locationProvider) {
  // Configure existing providers
  $locationProvider.hashPrefix('!');
});
</pre>

<p>Then you can create an injector and load your modules like this:</p>

<pre class="prettyprint linenums">
var injector = angular.injector(['ng', 'MyModule'])
</pre>

<p>However it's more likely that you'll just use
<a href="api/ng.directive:ngApp"><code>ngApp</code></a> or
<a href="api/angular.bootstrap"><code>angular.bootstrap</code></a> to simplify this process for you.</p></div>
<h2 id="Usage">Usage</h2>
<div class="usage"><pre class="prettyprint linenums">angular.module(name[, requires], configFn);</pre>
<h3 id="Parameters">Parameters</h3>
<ul class="parameters"><li><code ng:non-bindable="">name – {!string} – </code>
<p>The name of the module to create or retrieve.</p></li>
<li><code ng:non-bindable="">requires<i>(optional)</i> – {Array.&lt;string&gt;=} – </code>
<p>If specified then new module is being created. If unspecified then the
the module is being retrieved for further configuration.</p></li>
<li><code ng:non-bindable="">configFn – {Function} – </code>
<p>Option configuration function for the module. Same as
<a href="api/angular.Module#config"><code>Module#config()</code></a>.</p></li>
</ul>
<h3 id="Returns">Returns</h3>
<div class="returns"><code ng:non-bindable="">{module}</code><p>new module with the <a href="api/angular.Module"><code>angular.Module</code></a> api.</p></div>
</div>
</div>