knowhow-server
Version:
A personal workflow engine that can manage and use any network connected host
51 lines (50 loc) • 3.93 kB
HTML
<a href="http://github.com/angular/angular.js/tree/v1.2.9/src/Angular.js#L1100" class="view-source btn btn-action"><i class="icon-zoom-in"> </i> View source</a><a href="http://github.com/angular/angular.js/edit/master/src/Angular.js" class="improve-docs btn btn-primary"><i class="icon-edit"> </i> Improve this doc</a><h1><code ng:non-bindable="">ngApp</code>
<div><span class="hint">directive in module <code ng:non-bindable="">ng</code>
</span>
</div>
</h1>
<div><h2 id="description">Description</h2>
<div class="description"><div class="ng-directive-page ng-directive-ngapp-page"><p>Use this directive to <strong>auto-bootstrap</strong> an AngularJS application. The <code>ngApp</code> directive
designates the <strong>root element</strong> of the application and is typically placed near the root element
of the page - e.g. on the <code><body></code> or <code><html></code> tags.</p>
<p>Only one AngularJS application can be auto-bootstrapped per HTML document. The first <code>ngApp</code>
found in the document will be used to define the root element to auto-bootstrap as an
application. To run multiple applications in an HTML document you must manually bootstrap them using
<a href="api/angular.bootstrap"><code>angular.bootstrap</code></a> instead. AngularJS applications cannot be nested within each other.</p>
<p>You can specify an <strong>AngularJS module</strong> to be used as the root module for the application. This
module will be loaded into the <a href="api/AUTO.$injector"><code>AUTO.$injector</code></a> when the application is bootstrapped and
should contain the application code needed or have dependencies on other modules that will
contain the code. See <a href="api/angular.module"><code>angular.module</code></a> for more information.</p>
<p>In the example below if the <code>ngApp</code> directive were not placed on the <code>html</code> element then the
document would not be compiled, the <code>AppController</code> would not be instantiated and the <code>{{ a+b }}</code>
would not be resolved to <code>3</code>.</p>
<p><code>ngApp</code> is the easiest, and most common, way to bootstrap an application.</p>
<p> <h4 id="description_source">Source</h4>
<div source-edit="ngAppDemo" source-edit-deps="angular.js script.js" source-edit-html="index.html-0" source-edit-css="" source-edit-js="script.js-1" source-edit-json="" source-edit-unit="" source-edit-scenario="" source-edit-protractor=""></div>
<div class="tabbable"><div class="tab-pane" title="index.html">
<pre class="prettyprint linenums" ng-set-text="index.html-0" ng-html-wrap="ngAppDemo angular.js script.js"></pre>
<script type="text/ng-template" id="index.html-0">
<div ng-controller="ngAppDemoController">
I can add: {{a}} + {{b}} = {{ a+b }}
</script>
</div>
<div class="tab-pane" title="script.js">
<pre class="prettyprint linenums" ng-set-text="script.js-1"></pre>
<script type="text/ng-template" id="script.js-1">
angular.module('ngAppDemo', []).controller('ngAppDemoController', function($scope) {
$scope.a = 1;
$scope.b = 2;
});
</script>
</div>
</div><h4 id="description_demo">Demo</h4>
<div class="well doc-example-live animate-container" ng-embed-app="ngAppDemo" ng-set-html="index.html-0" ng-eval-javascript="script.js-1"></div>
</div></div>
<h2 id="usage">Usage</h2>
<div class="usage">as attribute<pre class="prettyprint linenums"><ANY ng-app="{angular.Module}">
...
</ANY></pre>
<h4 id="usage_parameters">Parameters</h4><table class="variables-matrix table table-bordered table-striped"><thead><tr><th>Param</th><th>Type</th><th>Details</th></tr></thead><tbody><tr><td>ngApp</td><td><a href="" class="label type-hint type-hint-angular">angular.Module</a></td><td><div class="ng-directive-page ng-directive-ngapp-page"><p>an optional application
<a href="api/angular.module"><code>module</code></a> name to load.</p>
</div></td></tr></tbody></table></div>
</div>