Angular JS Expressions

  • Angular js expressions can be written inside double braces:{{expression}}
  • It can also be written inside a directive : 

                        ng-bind="expression"

  • Angular JS will resolve the expression, and return the result exactly where the expression is written.
  • AngularJS expressions are much like javascript expressions they can contains constant, variables operators an functions

eg 

{{5+5}}

or
 
{{fname+" "+lname}}
<html>
         <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js">
         </script>   
<body>
<div ng-app=" ">
        <p>expression:{{5+5}}</p>
</div>
</body>
</html>
  • If we remove the ng-app directive, will display thexprron as it is, without solving it.
  • AngularJS will simply resolve the expression an return the result.

Angular JS V/S Javascript expressions

Angular JS expression :

  • Contain lirals, operators and variables.
  • can be written inside the html
  • Do not support conditionals loops and exceptions
  • support filter

JavaScript Expressions:

  • Contain litrals,operators and vriables.
  • cannot be written inside the html
  • javascript support conditionals,loops, and expressions.
  • never support filter
Posted on by