home

Angularjs Expressions

Angularjs expression are views, expressions binds data to html, expressions are written inside double braces {{write expression name here}}. Expression generate the data (view to user) where the expression is written.

Please refer the examples of angular expression, you will understand the complete concept and view of the expressions.

Angularjs expressions are much like javascript expressions.

If you remove ng-app directive in the code, code will be not generate the output. And this will shows as a normal code like this: My first expression: {{ 5 + 5 }}.

Angularjs Expression code

<div ng-app="">
 	My First Expression Result: {{ 5 + 5 }}
    //Result will be: My first Expression Result:10
</div>

Angularjs Using Number

<div ng-app="" ng-init="quantity=1;cost=100">
 1 British Pound equals almost: {{ quantity * cost }} 
</div>
// Result will be: 1 British Pound equals almost 100

Angularjs Using String (name) and number (age)

<div ng-app="" ng-init="Name=Michel; age=32">
   The name is: {{ Name}}  and age is: {{ age}}
</div>

//result of above code: The name is: Michel and age is: 34

Angularjs Using Object

There is similarity between the angularjs object and javascript object.

<div ng-init="people=['michelle','Obama', 'chikay burg', 'Jhon k']">

<ul ng-repeat="persons in people">
<li>{{person}}</li>
</ul>

</div>