Podcast/lib/angular/docs/partials/api/angular.module.html
2013-04-07 10:12:25 +02:00

54 lines
2.3 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<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 configuration 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>Optional 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>