AngularJS Development Guide 5: AngularJS expressions

Source: Internet
Author: User

AngularJS Development Guide 5: AngularJS expressions
AngularJS expressions are similar to Javascript code snippets, which are usually used in data binding and written in double braces, such as: {expression }}. The expression is processed using the $ parse method. The following are some valid AngularJS EXPRESSIONS 1 + 23*10 | currencyuser. name: You may think that the expression in AngularJS view is a Javascript expression, which is not completely correct because AngularJS does not use Javascript eval () functions to execute expressions. However, except for the following differences, you can regard AngularJS expressions as Javascript expressions: attribute expressions correspond to the current scope, unlike Javascript, it corresponds to a global window object. Undefined value allowed: AngularJS can allow undefined or null when executing an expression, unlike Javascript, which throws an exception. No control structure: you cannot use control structures such as "condition judgment", "loop", and "Throw exception" in AngularJS expressions. Filter (similar to the pipe operator in unix): You can pass the expression result through the filter chain. For example, convert a date object to a specified read-friendly format. If you want to use standard Javascript in an expression, you should write it as a controller method and then call this method in the expression. If you want to execute AngularJS expressions in Javascript, you can use the $ eval () method. For example: <! Doctype html>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.