Http://www.cnblogs.com/lzj0616/p/6440563.html[]angularjs 1.3.0 Developer's Guide (i)--what is angular?
ANGULARJS is a structural framework for dynamic Web Applications. It lets you use HTML as a template language, and you can extend the syntax of HTML to clearly and concisely represent the application Component. Angular's data binding mechanism and dependency injection mechanism exclude many of the code that you would otherwise have to Write. It acts on the browse side, making it a good partner for any server-side Technology.
Angular is designed to compensate for the lack of HTML in building Applications. HTML is a good declarative language for static documents, but it's a little weak to build web Apps. So I had to do some work to get the browser to do what I wanted.
In general, we resolve a mismatch between a dynamic app and a static Web page in the following ways:
- Libraries---a collection of functions that we use to write our web Applications. We encode ourselves as the subject, and then we call the library at the right time, such as Jquery.
- The framework---a particular implementation of Web applications that we can encode to implement concrete logic. here, The framework plays a leading role, and it can invoke your code in the specific logic of the application, for example: durandal, ember, and so On.
Angular uses a different Approach. It tries to compensate for Hmtl's lack of building applications by creating new HTML Constructs. The angular allows the browser to parse the new syntax through the structure we call Instructions. Including:
- By
{{}}
using data binding
- Iterate or hide dom fragments with DOM control structures
- Support for forms and forms validation
- The ability to associate code to DOM elements
- To make an HTML group a reusable component
Complete Client-side Solutions
In the overall engineering of building Web application clients, angular is not just a small part of it. It handles all of the DOM and Ajax glue code you've ever written, and puts them into a well-defined structure. This makes angular a bit "stubborn" when building crud applications, but it also tries to ensure that its "stubbornness" is just the beginning of a simple change. The angular offers the following features that can be flexibly changed:
- Everything you need to build a crud application includes: data-binding (data binding mechanism), Basic Templating Directives (basic template directive), form validation (form validation), routing (routing), Deep-linking (DEEP link), Reusable Components (reusable component), Dependency Injection (dependency injection).
- Testing aspects: unit-testing (unit test), end-to-end testing (end-to-end test), mocks, test harnesses (simulation and test tools).
- The specific directory layout and the seed application of the test script as a starting Point.
The lovely place of angular
For developers, angular simplifies application development by providing a higher level of abstraction. Like other abstractions, this brings the cost of Flexibility. In other words, not every application is suitable for using angular. Angular is primarily considered for building crud Applications. fortunately, Most Web applications are crud Applications. In order to understand what angular is good at, we have to figure out what kind of application is not suitable for using angular.
Both the animation and GUI editors are applications with dense and complex Dom Operations. This application is different from crud applications, and they are not suitable for use with angular. They are more suitable for using low-level abstract libraries, for example jQuery
.
Zen of Angular
Angular is based on the belief that the declarative language is better than the imperative language in creating an interface and assembling software methods, whereas imperative languages are better at expressing business Logic.
- Separating DOM operations from the application logic can improve the testability of the Code.
- Testing is treated the same way as coding, and the difficulty of testing depends partly on the structure of the Code.
- The front and back ends (client and server) are separated, and the front-end development is synchronized, which facilitates the reuse of front-end Code.
- The framework guides the developer through the process of building the application, from UI design to writing business logic to Testing.
- piecemeal, the complexity of the Simple.
Argular will save you from the following misery:
- registering a callback function: registering a callback function reduces the readability of the code and makes the code Fragmented. Generic code such as a callback function should be Removed. This will drastically reduce (due to the lack of javascript) the JavaScript code you have to write to make your application clearer.
- Programming HTML DOM operations: manipulating the DOM is a fundamental part of Ajax applications, but it's often tedious and error-prone. By declaring how the UI changes as the state of the application changes, you will be freed from the low-level Dom Operations. Most angular applications do not need to be edited to implement Dom operations, unless you do so, of Course.
- Read and write data in the UI page: CRUD operations occupy most of the tasks of Ajax Applications. The data stream read from the server is encapsulated into an internal object that is routed to an HTML form, and after the user modifies the form, the form is validated, the validation error message is displayed, and an internal model is sent back to the server, which produces a lot of duplicate code. and angular eliminates almost all repetitive code, so that the code only describes the overall process of the application, not the implementation details.
- write a lot of initialization code: you need to write a lot of basic code to implement a basic Ajax "Hello world" Application. With angular, you will be able to start your application easily by using service, and these services will be automatically injected into your application like Guice's dependency Injection. You can start developing your features Quickly. And you can control the initialization process of automated tests all the WAY.
Translation AngularJS 1.3.0 developer's Guide (i)--introduction (ext)