O'Reilly logo

Learning AngularJS by Brad Dayley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Relationship Between Scopes and Templates

Templates provide the view for an AngularJS application. HTML elements are defined as controllers, using the ng-controller attribute. Inside a controller HTML element and its children, the scope for that controller is available for expressions and other AngularJS functionality.

Values in a scope can be directly linked to the values of <input>, <select>, and <textarea> elements in the template, using the ng-model directive. This directive links the value of an element to a property name in the scope. When the user changes the value of the input element, the scope is automatically updated. For example, the following links the value of a number of an <input> element to the scope named valueA:

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required