Welcome to my five-part introduction to AngularJS! Because I was dissatisfied with the incoherency of the official AngularJS docs. I started writing this AngularJS guide on weekends during my senior year in college. But since starting full-time at Mozilla, my motivation and energy waned. So I am publishing it on my blog for the good of The Web!
This introduction comes complete with live demos and open-sourced examples.»
Angular scopes are objects that gives us access to the model. Remember the model holds the data and state of an MVC application. Besides applying context against which expressions are evaluated, scopes allow us to:
- access and manipulate the model.
- set event listeners to watch for whenever the model changes.
- enlighten Angular about asynchronous changes to the model.
Angular controllers help us initialize the initial state and add behavior to scope objects. Recall that controllers, in the classic MVC pattern, handle the business logic. They are the glue between the controller and the view. Controllers tell the view about changes to the model and manipulate the model when asked by from the view.»
Angular templates are an enhanced specification of HTML that, along with information from the model, becomes the rendered view that the user sees in the browser. Recall that the view, in the MVC pattern, generates the output representation with assistance from the model.
The templates were designed, through the use of directives, to be more declarative for specifying UI. They are the standard, static DOM sprinkled with various Angular elements that add behavior to make the view more dynamic and more closely binded with the model.»
The form, input, select, and textarea elements are augmented (as directives) in Angular for added sauce. Angular forms have a built-in awareness of their state, such as whether data has been inputted or whether the forms are valid. Angular forms provide
- two-way data binding with the model.
- form state.