bing
Flat 10% & upto 50% off + Free additional Courses. Hurry up!

AngularJS Expressions

 

AngularJS expression binds data to html. These are written in double braces {{expression}}. It prints the output as the data is written in braces. It works in similar way as ng-bind directives. These are the JavaScript like code snippets that are generally located in bindings.

 

AngularJS Numbers

e.g.

<!DOCTYPE html>

<html>

<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>

<body>

<div ng-app="" ng-init="salary=10000; month=4">

/* In case of ng-bind use <p>Total Salary: <span ng-bind="salary* month"></span></p> */

<p>Total salary: {{salary * month }}</p>

</div>

</body>

</html>

Output

Total salary: 40000

 

AngularJS Strings

e.g.

<!DOCTYPE html>

<html>

<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>

<body>

<div ng-app="" ng-init="firstName='Neha';lastName='Garg'">

/* In case of ng-bind use <p>Full name: <span ng-bind="firstName + ' ' + lastName"></span></p> */

<p>Full name: {{ firstName + " " + lastName }}</p>

</div>

</body>

</html>

Output

Full name: Neha Garg

 

AngularJS Objects

e.g.

<!DOCTYPE html>

<html>

<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>

<body>

<div ng-app="" ng-init="Employee={Name:'abc'}">

/*In case of ng-bind use <p>Name: <span ng-bind="Employee.Name"></span></p>*/

<p>Name: {{ Employee.Name }}</p>

</div>

</body>

</html>

Output

Name: abc

 

AngularJS Arrays

e.g.

<!DOCTYPE html>

<html>

<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>

<body>

<div ng-app="" ng-init="id=[1,2,3,4,5,6]">

/* <p> Last Id: <span ng-bind="id [5]"></span></p> */

<p>Last Id: {{ id[5] }}</p>

</div>

</body>

</html>

Output

Last Id: 6

 

Difference between AngularJS Expressions and JavaScript Expressions

AngularJS Expressions JavaScript Expressions
AngularJS expressions can be written inside HTML. JavaScript expressions cannot be written inside HTML.
Do not support conditionals, loops, and exceptions Support conditionals, loops, and exceptions
Support filters Does not support filters
Contain literals, operators, and variables. Contain literals, operators, and variables.

"0 Responses on AngularJS Expressions"

Training in Cities

Bangalore, Hyderabad, Chennai, Delhi, Kolkata, UK, London, Chicago, San Francisco, Dallas, Washington, New York, Orlando, Boston

100% Secure Payments. All major credit & debit cards accepted Or Pay by Paypal.

top

Sales Offer

  • To avail this offer, enroll before 05th December 2016.
  • This offer cannot be combined with any other offer.
  • This offer is valid on selected courses only.
  • Please use coupon codes mentioned below to avail the offer
offer-june

Sign Up or Login to view the Free AngularJS Expressions.