What is Angularjs?

Source: Internet
Author: User

First identify the source:

Https://code.angularjs.org/1.3.15/docs/guide/introduction

This is the official website for the 1.3.15 version of the instructions

What is Angular?

AngularJS is a structural the framework for dynamic web apps. It lets you use HTML as your template language and lets you extend HTML ' s syntax to express your application ' s components Clearly and succinctly. Angular ' s data binding and dependency injection eliminate much of the code you would otherwise has to write. And it all happens within the browser, making it a ideal partner with any server technology.

ANGULARJS is a structured framework for developing dynamic page apps.

With it, you can clearly and explicitly use HTML as the basis for extending its syntax to express (markup?). ) components on the interface.

Angularjs data binding and dependency injection can help you save a lot of tedious code.

And all of this is running in a browser, which can be perfectly combined with any server-side technology.

Concepts that need to be understood in advance:

1. Web App:

A Web application or Web app is any computer program, runs in a Web browser.

The computer program is placed in the browser.

Why do you put it in a browser?

Browsers worldwide, but not flexible;

The computer program is flexible (much more user-interactive), but not universal.

So put the computer program in the browser, in fact, the browser page has a high demand, like a program, the big, what to have.

So, Angularjs is the "in the browser, what to have what" requirements to meet the tool (framework).

2. Html:hypertext Markup Language

Hypertext:hypertext is text displayed in a computer display or other electronic devices with references to other text whi CH The reader can immediately access, or where text can is revealed progressively at multiple levels of detail. (Wikipedia)

Hypertext, which is the text displayed on the display, has a function similar to <a>, that is, to see other text at a point, or to see other text at 1.1.

HTML is the markup language used to create Web pages.

Web browsers can read HTML files and render them into visible or audible web pages. Browsers does not display the HTML tags and scripts, but use them to interpret the content of the page. (Wikipedia)

HTML is the standard markup language used to create pages.

A> HTML is the creation of a Web page (page);

B> HTML is the standard; (everyone uses it, so you're not very good with anything else.) But if one day the standard changes, but another standard, look at the instructions, it's OK, don't panic.

C> HTML is a markup language, is to follow the rules of others, simply mark your page, what content when the title (TITLE,H1, H2, ...) ), what content to display seriously (strong what)

What the browser does: the browser reads the HTML and completes the presentation according to the markup you write according to the standard. (Don't ask me why, I want to be quiet.) )

Then, the tags (or tags) and scripts in the HTML are not shown. (Have you ever seen a speaker read "Pause, Smile," and "there should be applause here"?) )

3. Application: Application

Computer software designed to help the user to perform specific tasks. (Wikipedia)

Application is the application, what is the application, helps the user to complete the specific task, the function of the software. Isn't that software? (mobile app is application's abbreviation?) )

4. Data binding: DataBinding

Data binding is the process of that establishes a connection between the application UI and business logic. (Wikipedia)

Data binding is the process of establishing a connection between the application interface and the business logic. Simply put, it is what is in logic, what you see, what you see changed, and what it becomes in logic. (Two-way data binding)

5. Dependency Injection: Dependency Injection

Dependency Injection (DI) is a design pattern where dependencies be defined in an application as part of the Configuratio N. (oreilly learning AngularJS 2015-3)

Dependency Injection (DI) is a design pattern that defines dependencies (which no one can run) as a configuration (a design pattern is a good idea when you are designing).

Angular is what HTML would has been, had it been designed for applications. HTML is a great declarative language for static documents. It does not contain much in the creating applications, and as a result building Web applications are an exercise in What does I have to does to trick the browser into doing what I want?

If HTML was originally designed in the direction of the application, it must have become angularjs. HTML is a powerful declarative language for static documents, but it does not contain too many things to create apps. So creating a web app becomes this: how do I get my browser to work as I want?

The impedance mismatch between dynamic applications and static documents are often solved with:

    1. a library -a collection of functions which is useful when writing web apps. Your code is in charge and it calls to the library when it sees fit. e.g. JQuery.
    2. Frameworks -a particular implementation of a Web application, where your code fills in the details. The framework is in charge and it calls to your code when it needs something app specific. e.g. Durandal, Ember, etc.

The resistance between dynamic applications and static documents is generally resolved as follows:

    1. Library: is a set of callable functions, your code is a host, you need to tune who to tune who. For example, Jqeury.
    2. Framework: An empty shelf developed specifically for web apps, you just need to fill in the details with your own code. In this way, the framework is hosting, handling most of the things, and, where appropriate, pulling the content from your code it needs (config, logic god horse). Like Durandal and Ember.

Angular takes another approach.  It attempts to minimize the impedance mismatch between document centric HTML and what a application needs by creating new HTML constructs. Angular teaches the browser new syntax through a construct we call directives.

Examples include:

    1. Data binding, as in {{}}.
    2. DOM control structures for repeating, showing and hiding dom fragments.
    3. Support for forms and form validation.
    4. Attaching new behavior to DOM elements, such as DOM event handling.
    5. Grouping of HTML into reusable.

Angularjs and they are not the same. It reduces the resistance to blending the document-centric HTML with the actual application by creating new HTML concepts. Angularjs This new concept to increase the browser's ability to parse the new HTML syntax, which we call directive. Instructions

Examples of new syntax:

    1. Syntax for data binding: {{}}
    2. Duplicate, show, hide DOM control structure of DOM fragment;
    3. form (form) support and verification;
    4. Adding behaviors to DOM elements, such as DOM message processing;
    5. Wrapping HTML into reusable components.

A Complete Client-side Solution

Angular is not a single piece in the overall puzzle of  building the client-side of a web application. It handles  All of the dom and ajax glue code you once wrote by  hand and puts it in a well-defined structure. this makes  Angular opinionated about how a CRUD  (Create, read, update,  delete)  application should be built. But while it is  Opinionated, it also tries to make sure that its opinion is  just a starting point you can easily change. angular comes  with the following out-of-the-box:

    1. Everything need to build a CRUD app in a cohesive set:data-binding, basic templating Directives, form validation, Rou Ting, deep-linking, reusable components and dependency injection.
    2. Testability story:unit-testing, End-to-end testing, mocks and test harnesses.
    3. Seed application with directory layout and test scripts as a starting point.

Angular is not part of the solution for creating a client Web App (it's a complete solution), it can take over all the DOM and Ajax code you write, and the organization is especially reasonable. This makes angular in the app processing crud (add-and-revise, you know) very stubborn (translation is very far-fetched). Fortunately, angular also tries to make DOM and Ajax operations simple and modifiable. The angular comes with the following out-of-the-box features:

    1. All the tools to work with CRUD: Data binding, basic template directives (the new HTML syntax that was mentioned earlier to teach the browser), form validation, jumps, deep-linking, reusable components, and dependency injection.
    2. Measurable occasions: Unit test, System test, simulation and tester.
    3. (Forgive me for incompetence, I don't know what it means)

Deep-linking:

In the context of the world Wide Web, deep linking consists of using a hyperlink so links to a specific, generally searc Hable or indexed, piece of Web content on a website, rather than the home page. (This does not bother to turn over, learn software always inevitably look at English.) See Wikipedia)

End-to-end Testing:system testing. (Wikipedia)

Mock object:

In object oriented programming, mock objects is simulated objects that mimic the behavior of real objects in controlled W Ays. A programmer typically creates a mock object to test the behavior of some other object, in much the same-a-to-a car de Signer uses a crash test dummy to simulate the dynamic behavior of a human in vehicle impacts. Simulation is a dummy in a car crash test. Everything is real, it's fake.

Angular ' s sweet spot

angular simplifies application development by presenting a higher  Level of abstraction to the developer. like any abstraction, it  comes at a cost of flexibility. In other words, not  every app is a good fit for angular. angular was built  with the crud application in mind. luckily crud applications  represent the majority of web applications. to understand what  Angular is good at, though, it helps to understand when an  app is not a good fit for angular.

Games and GUI Editors is examples of applications with intensive and tricky DOM manipulation. These kinds of apps is different from CRUD apps, and as a result is probably not a good fit for Angular. In these cases it is better to use a library with a lower level of abstraction, such as JQuery.

Where is angular sweet? (Under what circumstances will the use of angular be tasted?) )

Angular simplifies the development of web apps with a higher abstraction. Each of these high-level abstractions reduces flexibility. So angular is not all-in-all web apps. Angular's original intention is to do crud. Fortunately, most of the web apps on the market are just a few additions and deletions (oh hehe). So when do you use angular? Let's talk about when you shouldn't use it.

For example, if you want to develop a game, or if you want to change the UI, these need to manipulate DOM more than N. They're not the same as crud applications, so don't use angular. In this case, it is advisable to use a lower-level library, such as jquery.

The Zen of Angular

Angular is built around the belief, declarative code is better imperative when it comes to building UIs and wiring SOF Tware together, while imperative code was excellent for expressing business logic.

It is a-very good idea-to-decouple DOM manipulation from app logic. This dramatically improves the testability of the code.

It's a really, really good idea to regard app testing as equal in importance to app writing. Testing difficulty is dramatically affected by the the-the-by-the-code is structured.

It is a excellent idea to decouple the client side of a app from the server side. This allows development work to progress on parallel, and allows for reuse of both sides.

It's always good to make common tasks trivial and difficult tasks possible.

Zen of Angular

Angular believes in the idea that declarative languages are more suitable for writing interfaces, and imperative languages are better suited to handling business logic.

Separating the DOM manipulation from the app logic is often a good gray drop. This will significantly improve testability.

Depending on the test and the development of the same importance is also gray often good drop. The form of angular organization code also greatly improves the ease of testing.

The client and server side are independent of each other, it is often ash often good drop. This can be developed at the same time and is easy to reuse.

Gray often good drops, such as general problems become brain residue, complex problems become possible.

Angular frees you from the following pains:

  1. Registering callbacks:registering callbacks clutters your code, making it hard-see the forest for the trees. Removing common boilerplate code such as callbacks is a good thing. It vastly reduces the amount of JavaScript coding you has to does, and it makes it easier to see what your application does .
  2. Manipulating html dom programmatically: manipulating html dom is a  cornerstone of ajax applications, but it ' s cumbersome and  Error-prone. by declaratively describing how the ui should change  as your application state changes, you are freed from  low-level dom manipulation tasks. most applications written with  Angular never have to programmatically manipulate the dom, although  you can if you want to.
  3. Marshaling data to and from the ui: crud operations make  up the majority of ajax applications '  tasks. the flow of  marshaling data from the server to an internal object to  an html form, allowing users to modify the form, validating  the form, displaying validation errors, returning to an internal  model, and then back to the server, creates a lot of  boilerplate code. Angular eliminates almost all of this  Boilerplate, leaving code that describes the overall flow of the  application rather than all of the implementation details.
  4. Writing tons of initialization code just to get started:typically do need to write a lot of plumbing just to get a basic "Hello World" AJAX app working. With Angular can bootstrap your app easily using services, which is auto-injected into your application in a Guice-li Ke dependency-injection style. This allows-get started developing features quickly. As a bonus, you get full control over the initialization process in automated tests.

With angular, you can get away from your troubles and realize the following dreams:

    1. You do not have to register the function yourself;
    2. More organized manipulation of the DOM;
    3. Data from/To the UI are reorganized; (better organized)
    4. You don't have to write n more nonsense for writing logic.

What is Angularjs?

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.