search
HomeWeb Front-endHTML TutorialDetailed examples of AngularJS expressions

Recently I want to make a cross-platform (pc\app\pad) thing to play with, and have studied many technologies:

android, ios, H5, Bootrap, angular, angular2, ApiCloud, WeChat applet

Except for the shackles (systems) of android and ios, everything else can be cross-platform. In particular, ApiCloud and WeChat applets are very popular for developing SDK-level solutions, but in terms of technical sovereignty, they are too dependent on others. Things,

H5 and bootstrap are very good in responsiveness, and the front-end and back-end frameworks can basically be contracted.

Of course there are many front-end frameworks such as vue.js and so on.

I don’t know why, but I am currently interested in Angular. Interest is the most shameless behavioral appeal. For example, you have a strong interest in a beautiful girl, and then. . . . (~~~Just kidding)

Then I have to find a way to get close to "her" ~~

I want to get close to angular ~~

Start by gathering information:

Where did she come from?

AngularJS[1] was born in 2009, created by Misko Hevery and others, and later acquired by Google. It is an excellent front-end JS framework that has been used in many Google products. AngularJS has many features, the most core of which are: MVC, modularization, automated two-way data binding, semantic tags, dependency injection, etc.

What’s so charming about her?

AngularJS is designed to overcome the shortcomings of HTML in building applications. HTML is a good declarative language for pseudo-static text display design, but it is weak when it comes to building WEB applications.

Usually, we use the following technologies to solve the shortcomings of static web page technology in building dynamic applications:
Class library - A class library is a collection of functions that can help you write WEB applications. . It's your code that takes control, and it's you who decides when to use the library. Class libraries include: jQuery and other
frameworks - A framework is a special, already implemented WEB application. You only need to fill it with specific business logic. The framework here plays a leading role, calling your code according to specific application logic. Frameworks include: knockout, sproutcore, etc.
------Okay, not charming enough
AngularJS provides developers with a higher level Abstractions to simplify application development. As with other abstraction techniques, some flexibility is lost. In other words, not all applications are suitable for AngularJS. The main concern of AngularJS is building CRUD applications. Fortunately, at least 90% of WEB applications are CRUD applications. But to understand what is suitable for building with AngularJS, you need to understand what is not suitable for building with AngularJS.
For example, games, graphical interface editors, applications with frequent and complex DOM operations are very different from CRUD applications, and they are not suitable to be built with AngularJS. In situations like this it might be better to use some lighter, simpler technology like jQuery.
------Are you excited?
----------I have to say that all our Internet behaviors are nothing more than CRUD on data points one by one, such as adding and subtracting items from the shopping cart (+ - ), check air tickets, tickets, clear WeChat friends who are not in contact, place an order----------
Further exploration:
In the tag, we use an ng-app identifier to indicate that this is an AngularJS application.
This ng-app identifier will cause AngularJS to automatically initialize your application.
We use the <script> tag to load the AngularJS script: </script>
> ;
By setting the ng-model attribute in the tag, AngularJS will automatically perform two-way binding of data.
We also performed some simple data verification at the same time:
Quantity:Cost:
The widget of this input box looks very ordinary, but if you realize the following points, it will be extraordinary:
After the page is loaded, AngularJS will generate variables with the same name according to the model name (qty, cost) declared in the widget.
You can think of these variables as M (Model) in the MVC design pattern;
Note that the input in the widget above has special capabilities.
If you have not entered data or the entered data is invalid, the input box will automatically turn red. This new feature of the input box makes it easier for developers to implement common field validation functions in CRUD applications.
Finally, we can take a look at the mysterious double braces {{}}:
Total:{{qty *cost |currency}} This {{expression}} tag is the data binding of AngularJS. The expression can be a combination of expression and filter ({{ expression | filter }}).
AngularJS provides filters to format input and output data.
In the above example, the expression in {{}} allows AngularJS to multiply the data obtained from the input box, then format the multiplication result into the local currency style, and then output it to the page.
It is worth mentioning that we neither called any AngularJS methods nor wrote any specific logic like using a framework, we just completed the above functions.
The reason behind this implementation is that the browser has done more work than before to generate static pages, so that it can meet the needs of dynamic WEB applications.
AngularJS lowers the threshold for developing dynamic WEB applications to the point where no class library or framework is required.
Angular believes that when building a view (UI) and writing software logic at the same time, declarative code will be much better than imperative code. Although the command Formula code is very suitable for expressing business logic.
It is a very good idea to decouple DOM operations and application logic, which can greatly improve the adjustability of the code;
It is a very, very good idea to treat testing and development equally. The idea is that the difficulty of testing depends to a large extent on the structure of the code;
Decoupling the client and server is a particularly good practice, which allows both sides to develop in parallel and makes the code on both sides can be reused;
If the framework can guide developers throughout the entire development process: from designing UI, to writing business logic, to testing, it will be of great help to developers;
It is always good to "reduce complexity to simplicity, and reduce complexity to zero".
AngularJS can free you from the following nightmares

AngularJS Expression

Edit
AngularJS expressions are written within double curly braces: {{ expression }}. [2]
AngularJS expression binds 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.
Example{{ 5 + 5 }} or {{ firstName + " " + lastName }}
Initial understanding of angular , waiting for the next appointment~~~ Do you want to go together~~~ V-V

The above is the detailed content of Detailed examples of AngularJS expressions. 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
HTML as a Markup Language: Its Function and PurposeHTML as a Markup Language: Its Function and PurposeApr 22, 2025 am 12:02 AM

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

The Future of HTML, CSS, and JavaScript: Web Development TrendsThe Future of HTML, CSS, and JavaScript: Web Development TrendsApr 19, 2025 am 12:02 AM

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

HTML: The Structure, CSS: The Style, JavaScript: The BehaviorHTML: The Structure, CSS: The Style, JavaScript: The BehaviorApr 18, 2025 am 12:09 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The Future of HTML: Evolution and Trends in Web DesignThe Future of HTML: Evolution and Trends in Web DesignApr 17, 2025 am 12:12 AM

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

HTML vs. CSS vs. JavaScript: A Comparative OverviewHTML vs. CSS vs. JavaScript: A Comparative OverviewApr 16, 2025 am 12:04 AM

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTML: Is It a Programming Language or Something Else?HTML: Is It a Programming Language or Something Else?Apr 15, 2025 am 12:13 AM

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML: Building the Structure of Web PagesHTML: Building the Structure of Web PagesApr 14, 2025 am 12:14 AM

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

From Text to Websites: The Power of HTMLFrom Text to Websites: The Power of HTMLApr 13, 2025 am 12:07 AM

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.