Expressions of Angular JS
AngularJS expressions written into double 2nd brackets: {{ expression }}.
AngularJS expressions also be written inside a directive: ng-bind="expression".
AngularJS will resolve the expression, and return the result exactly where the expression is written.
AngularJS expressions are much like JS expressions:
It’s contained literals, operators, and variables.
Example
{{ 2+ 2}} or {{ FirstName + " " + LastName }}
Example
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<body>
<div ng-app="">
<p>Expression 1: {{ 2 + 2 }}</p>
</div>
</body>
</html>
If you remove the ng-app directive, HTML will display the expression as it is, without solving it:
Example
Easy to write expressions wherever you want, AngularJS will simply resolve the expression and return the result.
“Let AngularJS change the value of CSS properties.”
Can change the color of the input box below, by changing its value:
blue
Example
AngularJS Numbers
AngularJS numbers are like as JavaScript numbers:
Example
Same example using ng-bind:
Example
Using ng-init is not very common. You will learn a better way to initialize data in the chapter about controllers.
AngularJS Strings
AngularJS strings are much like JavaScript strings:
Example
Same example using ng-bind:
Example
AngularJS Objects
AngularJS objects are like JavaScript objects:
Example
Same example using ng-bind:
Example
Arrays
AngularJS arrays are much more like JavaScript arrays:
Example
Same example using ng-bind:
Example
Thank You
Next Will Come Soon About “ Angular JS Modules “
Required fields are marked *
Get all latest content delivered to your email free.