What are AngularJS expressions?

In AngularJS, the expressions bind the data related to applications with HTML. The simple expressions are normally in the form:

  • x+yx + y
  • 2+32 + 3

Whereas in AngularJS, expressions are written in double curly braces. For example: {{ 2+3 }} is a form of an expression in AngularJS.

Syntax

{{ Any expression }}

Example

  • HTML
Code example 1

Explanation

  • Line 7: Use the angular.min.js file to access the AngularJS library.

  • Line 12: The expression 2+32+3 is in double curly braces to make it an AngularJS expression. The expression {{ 2+3 }} will thus return the value 55 as a result.

Example

  • HTML
Code example 2

Explanation

  • Line 5: Use the angular.min.js file to access the AngularJS library.

  • Line 15: Initialize the variable name with the string Educative.

  • Line 17: The variable name is in double curly braces to print the content stored in the variable.

Copyright ©2024 Educative, Inc. All rights reserved