Home  >  Article  >  Web Front-end  >  How to use AngularJS expressions? Detailed explanation of the use of expressions in angularjs

How to use AngularJS expressions? Detailed explanation of the use of expressions in angularjs

寻∝梦
寻∝梦Original
2018-09-08 14:49:311141browse

This article mainly talks about the details of the use of expressions in angularjs, as well as the use of numbers, arrays, and strings in angularjs. Let us take a look at this article together.

AngularJS Expression:

AngularJS uses Expression to bind data to HTML .

AngularJS expressions are written within double curly braces: {{ expression }}.

AngularJS expressions bind data to HTML, which is similar to the ng-bind directive.

AngularJS will "output" data where the expression is written.

AngularJS expressions are much like JavaScript expressions: they can contain literals, operators, and variables.

Instance{{ 5 5 }} or {{ firstName " " lastName }}

AngularJS Number

AngularJS Number Like JavaScript numbers:

AngularJS Example


##

Total price: {{ quantity * cost }}



Same example using ng-bind:

##AngularJS Example


##


Total price: < ;/p>

How to use AngularJS expressions? Detailed explanation of the use of expressions in angularjs Using ng-init is not very common. You'll learn a better way to initialize data in the Controllers chapter.

AngularJS Strings

AngularJS Strings are just like JavaScript Strings:

AngularJS Examples



Name: { { firstName " " lastName }}


Same instance using ng-bind:


##AngularJS Example


Name:



(If you want to see more, go to the PHP Chinese website

AngularJS Development Manual to learn)

AngularJS object:


AngularJS object is like JavaScript object:

AngularJS Example


##

The last name is {{ person.lastName }}



Same example using ng-bind:



AngularJS Example


Last name is



Try it »


AngularJS arrays

AngularJS arrays are like JavaScript arrays:

AngularJS Example


##

The third value is {{ points[2] }}



The same instance using ng-bind:


AngularJS instance


The third value is



AngularJS expressions and JavaScript expressions

Similar to JavaScript expressions, AngularJS expressions can contain letters, operators, and variables.

Unlike JavaScript expressions, AngularJS expressions can be written in HTML.

Unlike JavaScript expressions, AngularJS expressions do not support conditional judgments, loops and exceptions.

Unlike JavaScript expressions, AngularJS expressions support filters.

This article ends here (if you want to see more, go to the PHP Chinese website

AngularJS User Manual to learn). If you have any questions, you can leave a message below.

The above is the detailed content of How to use AngularJS expressions? Detailed explanation of the use of expressions in angularjs. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn