Directives That Bind the Model to Page Elements

AngularJS templates enable you to bind data in the scope directly to what is displayed in HTML elements. You can bind data to the view in several ways, including these:

Value: You can directly represent the value of a form element in the scope. For example, a text input can be a String variable in the scope, but a check box would be represented by a Boolean value.

HTML: You can represent the value of data in the scope in the HTML output of an element by using expressions such as this:

<p>{{myTitle}}</p>

Attributes: The value of HTML element attributes can reflect the data in the scope by using expressions in the definition such as this:

<a ng-href="/{{hash}}/index.html">{{hash}}</a>. ...

Get Learning AngularJS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.