AngularJS Example 3


Consider the simple line of output:

My first expression: {{ 5 + 5 }}

The above was not created with the number ten but with 5 + 5 surrounded with two curly brackets on each side. The sentence is within the HTML paragraph tags, which are within div tags. The first div tag has the attribute ng-app=””. AngularJS expressions are much like JavaScript expressions: They can contain literals, operators, and variables. An AngularJS expression uses two sets of curly brackets: {{ }}.

<div ng-app="">
  <p>My first expression: {{ 5 + 5 }}</p>
</div>

If you remove the ng-app directive, HTML will display the expression as it is, without solving it.

My first expression: {{ 5 + 5 }}

AngularJS binds data to HTML using Expressions. AngularJS expressions can be written inside double braces. {{ expression }}. AngularJS expressions can also be written inside a directive: ng-bind=”expression”. AngularJS will resolve the expression, and return the result exactly where the expression is written.

Leave a comment

Your email address will not be published. Required fields are marked *