top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What are expressions in AngularJS?

0 votes
196 views

Expressions in AngularJS are just like JavaScript code snippets. JavaScript code is usually written inside double braces: {{expression}}. In other words, Angular Expressions are JavaScript code snippets with limited sub-set. Expressions are included in the HTML elements. 

Like JavaScript expressions, AngularJS expressions can also have various valid expressions. We can use the operators between numbers and strings, literals, objects and arrarys inside the expression {{ }}. For example,

  • {{ 2 + 2 }} (numbers)
  • {{Name + " " + email}} (string)
  • {{ Country.Name }} (object)
  • {{ fact[4] }} (array)

    example

Example

  1. <div ng-controller="appController">  
  2.     <span>   
  3. 4+5 = {{4+5}}   
  4. </span>  
  5.     <br />  
  6.     <br />  
  7.     <span ng-init="quantity=5;cost=25">   
  8. Total Cost = {{quantity * cost}}   
  9. </span>  
  10. </div>  
posted Sep 28, 2017 by Shivaranjini

  Promote This Article
Facebook Share Button Twitter Share Button LinkedIn Share Button

...