Secret ingredients to quality software


Do you understand that with Angular you read and write to the model... never to the page? (a.k.a. Forget about jQuery)

Last updated by Tiago Araujo on 05 Mar 2019 05:56 pm (about 2 years ago) See History

The most common mistake that developers make when moving from jQuery to Angular is that they continue to think about updating the page.

understand jquery
Figure: In jQuery, you design a page and then use jQuery to perform interactions with the page e.g. reading and setting the values of input boxes, updating the content of divs or handling button events

understand badcode
Figure: Bad Example - using jQuery on Angular views will lead to worlds of pain

A fundamental principal of Angular is that you build a Model in JavaScript (or TypeScript) and then on your view you just databind your UI elements to the model. Any changes that are made are made to the model and the view updates automatically.

In Angular, you do not interact with the page you update the model, and the page is just displaying a view of the model.

understand goodcode
Figure: Good Example - In both AngularJs & Angular 2.0 jQuery is not required on the view. The view binds to properties on a JavaScript model

Further reading:

Adam StephensenAdam Stephensen

We open source. This page is on GitHub