Chapter 3. Views and controllers
This chapter covers
- What a view is in AngularJS
- Creating controllers to manage views
- Declaring properties and methods in a controller
- Binding to properties and expressions in an AngularJS template
- Best practices for creating views and controllers and how to test them
In this chapter, we’ll get into the most fundamental and important facet in AngularJS. You’ll learn what views and controllers are in AngularJS, and more importantly the relationship that they have with each other. There may be some edge case that we haven’t considered but by our approximation, everything in AngularJS is designed to either support views and controllers, or to extend their functionality.
The goal of this chapter is to build out the storyboard view in Angello, as seen in figure 3.1. This storyboard view will give you plenty of opportunities to learn how a view works in AngularJS and how you can control that view with a controller. You’ll learn how to take an array of JavaScript objects and display them as user stories, and then how to create, update, and delete items in the user story collection by exposing that functionality via the controller.