We now have a youtube channel. Subscribe!

AngularJS | Expressions

AngularJS Expressions

Hello folks! welcome back to a new section of our tutorial on AngularJS. In this tutorial, we're going to be studying about AngularJS Expressions.

Expressions binds application data to Html. Expressions are written inside double curly braces such as {{expression}}. Expressions acts similar to ngbind directives. AngularJS expressions are pure JavaScript expression and output the data where they are used.


<p>Expense on Books : {{cost * quantity}} Rs</p>


<p>Hello {{student.firstname + " " + student.lastname}}!</p>


<p>Roll No: {{student.rollno}}</p>


<p>Marks(Math): {{marks[3]}}</p>


The following example illustrates the use of all the above mentioned expressions -

Create a file testAngularJS.html.

      <title>AngularJS Expressions</title>
      <h1>Sample Application</h1>
      <div ng-app = "" ng-init = "quantity = 1;cost = 30; 
         student = {firstname:'Kennedy',lastname:'Nkpara',rollno:102};
         marks = [80,90,75,73,60]">
         <p>Hello {{student.firstname + " " + student.lastname}}!</p>
         <p>Expense on Books : {{cost * quantity}} USD</p>
         <p>Roll No: {{student.rollno}}</p>
         <p>Marks(Math): {{marks[3]}}</p>
      <script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js">


Open the file testAngularJS.html in any web browser of your choice to see the result -


Sample Application

Hello Kennedy Nkpara!

Expense on Books : 30 USD

Roll No: 102

Marks(Math): 73

Alright guys! This is where we are going to be rounding up for this tutorial. In our next tutorial, we are going to be studying about AngularJS Controllers.

Feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.

Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.

Thanks for reading and bye for now.

Post a Comment

Hello dear readers! Please kindly try your best to make sure your comments comply with our comment policy guidelines. You can visit our comment policy page to view these guidelines which are clearly stated. Thank you.
© 2023 ‧ WebDesignTutorialz. All rights reserved. Developed by Jago Desain