https://docs.angularjs.org/guide/introduction
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 are examples of applications with intensive and tricky DOM manipulation. These kinds of apps are different from CRUD apps, and as a result are probably not a good fit for Angular. In these cases it may be better to use a library with a lower level of abstraction, such as jQuery.
Angular frees you from the following pains:
Registering callbacks:
Registering callbacks clutters your code, making it hard to 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 have to do, and it makes it easier to see what your application does.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.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.Writing tons of initialization code just to get started:
Typically you need to write a lot of plumbing just to get a basic "Hello World" AJAX app working. With Angular you can bootstrap your app easily using services, which are auto-injected into your application in a Guice-like dependency-injection style. This allows you to get started developing features quickly. As a bonus, you get full control over the initialization process in automated tests.Conceptual Overview
This section briefly touches on all of the important parts of AngularJS using a simple example. For a more in-depth explanation, see thetutorial.Concept | Description |
---|---|
Template | HTML with additional markup |
Directives | extend HTML with custom attributes and elements |
Model | the data shown to the user in the view and with which the user interacts |
Scope | context where the model is stored so that controllers, directives and expressions can access it |
Expressions | access variables and functions from the scope |
Compiler | parses the template and instantiates directives and expressions |
Filter | formats the value of an expression for display to the user |
View | what the user sees (the DOM) |
Data Binding | sync data between the model and the view |
Controller | the business logic behind views |
Dependency Injection | Creates and wires objects and functions |
Injector | dependency injection container |
Module | a container for the different parts of an app including controllers, services, filters, directives which configures the Injector |
Service | reusable business logic independent of views |
댓글 없음:
댓글 쓰기