Trending News
Home / Web Development / Angular Js / AngularJS Expression

AngularJS Expression

Angularjs expressions are used to bind the data to html.The angularjs expressions are written inside {{ expression }} . It also written inside a directive like ng-bind=”expression”. AngularJS expressions are much like JavaScript expressions. They can contain literals, operators, and variables.

Eg: {{ 15 + 15 }} or {{ firstName + ” ” + lastName }}



The output of above code is like: My first expression: 30.

If you remove the ng-app directive, HTML will display the expression as it is, without solving it:




The output of above code is like: My first expression: {{ 15 + 15 }}.

AngularJS application expressions are pure javascript expressions and outputs the data where they are used.

Using object

Using numbers

In the AngularJS expressions with numbers example we just want to show a simple addition of two number variables called number1 and number2 and displayed their total(after addition) value.

The output of above code is like: After Addition: 40.




Using array

The output as :



Subject1 :11
Subject2 :15
Subject3 :29

Using strings

In the AngularJS expressions with string example, we are going to define 2 strings of “firstName” and “lastName” and display them using expressions accordingly.




The output of above code is like:
First Name : Pritty
last Name : Times

Loading Facebook Comments ...
Social Media Auto Publish Powered By : XYZScripts.com