Expression in AngularJS
Expression is used to bind application data to HTML tags. Expression is written in {{expression}}. Expression has a similar way of operating as the ng-bind directive. The expressions in the AngularJS application are pure JavaScript expressions and the output is the data we use.
Use numbers in Expression in AngularJS:
Bookshelf: {{cost * quantity}} 000 VND
Use strings in Expression in AngularJS:
Hello {{student.firstname + "" + student.lastname}}!
Use objects in Expression in AngularJS:
Student ID: {{student.rollno}}
Use arrays in Expression in AngularJS:
Test Score (Tin): {{marks [3]}}
For example:
Below is an example for the expressions described above:
viduExpression.html
Examples of Expressions in AngularJS
QTM application
Hello {{student.firstname + "" + student.lastname}}!
Bookshelf: {{cost * quantity}} 000 VND
Student ID: {{student.rollno}}
Test Score (Tin): {{marks [3]}}
Result
Open the viduExpression.html page on the web browser and see the results below.
According to Tutorialspoint
Previous post: The Directive in AngularJS
Next lesson: Controller component in AngularJS