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 }}








My first expression: {{ 15 + 15 }}

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:





My first expression: {{ 15 + 15 }}




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

Roll No: {{student.firstname}}

Using numbers

Total amount- Books : {{cost * numbers}} Rs

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.

  
  
  
  

After Addition: {{number1+ number2 }}

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




Using array

Marks(Math): {{marks[3]}}






  

Subject1 : {{marks[0] }}
Subject2 : {{marks[1] }}
Subject3 : {{marks[2] }}

The output as :



Subject1 :11
Subject2 :15
Subject3 :29

Using strings

Hello {{student.firstname + " " + student.lastname}}!

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




	  


    
First Name : {{firstName}}
last Name : {{lastName}}




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

3 thoughts on “AngularJS Expression

  1. ecopies.ru

    На этом сайте публикуются актуальные события России и мира .
    Здесь можно прочитать значимые статьи по разным темам .
    https://ecopies.rftimes.ru/
    Читайте важнейших новостей в любое время.
    Проверенная информация и скорость подачи в каждой публикации .

  2. Donnynub

    This extensive resource serves as an thorough guide to the realm of modern video surveillance, providing valuable information for both skilled CCTV installers and security-conscious companies seeking to enhance their surveillance setup.
    Video Surveillance Software
    The site presents a comprehensive analysis of cloud-based video surveillance systems, examining their strengths, drawbacks, and real-world applications.

  3. WilliamHox

    На данном сайте вы можете найти полезной информацией о терапии депрессии у людей старшего возраста. Здесь представлены советы и обзоры способов лечения этим заболеванием.
    http://complainanything.com/zh-hans/node/4108?page=105

Leave a Reply

Your email address will not be published.