What Is AngularJS?

AngularJS may be a structural framework for dynamic web apps. It allows you to use HTML as your template language and allows you to extend HTML's syntax to precise your application's components clearly and succinctly. AngularJS's data binding and dependency injection eliminate much of the code you'd otherwise need to write. And it all happens within the browser, making it a perfect partner with any server technology.

AngularJS is what HTML would are , had it been designed for applications. HTML may be a great declarative language for static documents. It doesn't contain much within the way of making applications, and as a result building web applications is an exercise in what do I even have to try to to to trick the browser into doing what I want?

The impedance mismatch between dynamic applications and static documents is usually solved with:

a library - a set of functions which are useful when writing web apps. Your code is responsible and it calls into the library when it sees fit. E.g., jQuery.
frameworks - a specific implementation of an internet application, where your code fills within the details. The framework is responsible and it calls into your code when it needs something app specific. E.g., durandal, ember, etc.
AngularJS takes another approach. It attempts to attenuate the impedance mismatch between document centric HTML and what an application needs by creating new HTML constructs. AngularJS teaches the browser new syntax through a construct we call directives. Examples include:

Data binding, as in {{}}.
DOM control structures for repeating, showing and hiding DOM fragments.
Support for forms and form validation.
Attaching new behavior to DOM elements, like DOM event handling.
Grouping of HTML into reusable components.
A complete client-side solution
AngularJS isn't one piece within the overall puzzle of building the client-side of an internet application. It handles all of the DOM and AJAX glue code you once wrote by hand and puts it during a well-defined structure. This makes AngularJS opinionated about how a CRUD (Create, Read, Update, Delete) application should be built. But while it's opinionated, it also tries to form sure that its opinion is simply a start line you'll easily change. AngularJS comes with the subsequent out-of-the-box:

Everything you would like to create a CRUD app during a cohesive set: Data-binding, basic templating directives, form validation, routing, deep-linking, reusable components and dependency injection.
Testability story: Unit-testing, end-to-end testing, mocks and test harnesses.
Seed application with directory layout and test scripts as a start line .
AngularJS's sweet spot
AngularJS simplifies application development by presenting a better level of abstraction to the developer. like all abstraction, it comes at a price of flexibility. In other words, not every app may be a good fit AngularJS. AngularJS was built with the CRUD application in mind. Luckily CRUD applications represent the bulk of web applications. to know what AngularJS is sweet at, though, it helps to know when an app isn't an honest fit AngularJS.

Games and GUI editors are samples of applications with intensive and tricky DOM manipulation. These sorts of apps are different from CRUD apps, and as a result are probably not an honest fit AngularJS. In these cases it's going to be better to use a library with a lower level of abstraction, like jQuery.

The Zen of AngularJS
AngularJS is made round the belief that declarative code is best than imperative when it involves building UIs and wiring software components together, while imperative code is superb for expressing business logic.

It is a really good idea to decouple DOM manipulation from app logic. This dramatically improves the testability of the code.
It is a very , specialized idea to take app testing as equal in importance to app writing. Testing difficulty is dramatically suffering from the way the code is structured.
It is a superb idea to decouple the client side of an app from the server side. this enables development work to progress in parallel, and allows for reuse of each side .
It is very helpful indeed if the framework guides developers through the whole journey of building an app: From designing the UI, through writing the business logic, to testing.
It is always good to form common tasks trivial and difficult tasks possible.
AngularJS frees you from the subsequent pains:

Registering callbacks: Registering callbacks clutters your code, making it hard to ascertain the forest for the trees. Removing common boilerplate code like callbacks may be a good thing. It vastly reduces the quantity of JavaScript coding you've got to try to to , and it makes it easier to ascertain what your application does.
Manipulating HTML DOM programmatically: Manipulating HTML DOM may be 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're free of low-level DOM manipulation tasks. Most applications written with AngularJS never need to programmatically manipulate the DOM, although you'll if you would like to.
Marshaling data to and from the UI: CRUD operations structure the bulk of AJAX applications' tasks. The flow of marshaling data from the server to an indoor object to an HTML form, allowing users to switch the shape , validating the shape , displaying validation errors, returning to an indoor model, then back to the server, creates tons of boilerplate code. AngularJS eliminates most of this boilerplate, leaving code that describes the general flow of the appliance instead of all of the implementation details.
Writing plenty of initialization code just to urge started: Typically you would like to write down tons of plumbing just to urge a basic "Hello World" AJAX app working. With AngularJS you'll bootstrap your app easily using services, which are auto-injected into your application during a Guice-like dependency-injection style. this enables you to urge started developing features quickly. As a bonus, you get full control over the initialization process in automated tests.

Comments

Popular posts from this blog

Introduction to Salesforce Connect

By the numbers: fraud statistics