forked from angular/code.angularjs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdev_guide.templates.html
60 lines (50 loc) · 2.8 KB
/
dev_guide.templates.html
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
<h1><code ng:non-bindable=""></code>
<span class="hint"></span>
</h1>
<div><p>An angular template is the declarative specification that, along with information from the model
and controller, becomes the rendered view that a user sees in the browser. It is the static DOM,
containing HTML, CSS, and angular-specific elements and angular-specific element attributes. The
angular elements and attributes direct angular to add behavior and transform the template DOM into
the dynamic view DOM.</p>
<p>These are the types of angular elements and element attributes you can use in a template:</p>
<ul>
<li><a href="guide/directive">Directive</a> — An attribute or element that
augments an existing DOM element or represents a reusable DOM component - a widget.</li>
<li><a href="api/ng.$interpolate"><code>Markup</code></a> — The double
curly brace notation <code>{{ }}</code> to bind expressions to elements is built-in angular markup.</li>
<li><a href="guide/dev_guide.templates.filters">Filter</a> — Formats your data for display to the user.</li>
<li><a href="guide/forms">Form controls</a> — Lets you validate user input.</li>
</ul>
<p>Note: In addition to declaring the elements above in templates, you can also access these elements
in JavaScript code.</p>
<p>The following code snippet shows a simple angular template made up of standard HTML tags along with
angular <a href="guide/directive">directives</a> and curly-brace bindings
with <a href="guide/expression">expressions</a>:</p>
<pre class="prettyprint linenums">
<html ng-app>
<!-- Body tag augmented with ngController directive -->
<body ng-controller="MyController">
<input ng-model="foo" value="bar">
<!-- Button tag with ng-click directive, and
string expression 'buttonText'
wrapped in "{{ }}" markup -->
<button ng-click="changeFoo()">{{buttonText}}</button>
<script src="angular.js">
</body>
</html>
</pre>
<p>In a simple single-page app, the template consists of HTML, CSS, and angular directives contained
in just one HTML file (usually <code>index.html</code>). In a more complex app, you can display multiple views
within one main page using "partials", which are segments of template located in separate HTML
files. You "include" the partials in the main page using the <a href="api/ng.$route"><code>$route</code></a> service in conjunction with the <a href="api/ng.directive:ngView"><code>ngView</code></a> directive. An
example of this technique is shown in the <a href="tutorial/index">angular tutorial</a>, in steps seven and
eight.</p>
<h3>Related Topics</h3>
<ul>
<li><a href="guide/dev_guide.templates.filters">Angular Filters</a></li>
<li><a href="guide/forms">Angular Forms</a></li>
</ul>
<h3>Related API</h3>
<ul>
<li><a href="api/index">API Reference</a></li>
</ul></div>