×

Html & Html5

The World's best Software Development Study Portal

AngularJS Expressions


Expressions are used to bind application data to HTML.
AngularJS resolves the expression, and return the result exactly where the expression is written.


Expressions can be written inside double braces: {{ expression }}
or
Written inside a directive: ng-bind="expression"


for example
{{ 5 + 5 }} or {{ firstName + " " + lastName }}


AngularJS Numbers
<div ng-app="" ng-init="quantity=1;cost=5">

{{ quantity * cost }}
or
<span ng-bind="quantity * cost">

AngularJS Strings
<div ng-app="" ng-init="firstName='John';lastName='Doe'">

{{ firstName + " " + lastName }}
or
<span ng-bind="firstName + ' ' + lastName">
AngularJS Objects
<div ng-app="" ng-init="person={firstName:'John',lastName:'Doe'}">

{{ person.lastName }}
or
<span ng-bind="person.lastName">

AngularJS Arrays
<div ng-app="" ng-init="points=[1,15,19,2,40]">

{{ points[2] }}
or
<span ng-bind="points[2]">


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