We saw in Chapter 1 how to create a very simple and trivial AngularJS application, which was basically the “hello world” of the AngularJS world. In this chapter, we will expand on that example.
We explore AngularJS modules and controllers, and create our very own controllers. Then we use these controllers to load data or state into our application, and manipulate the HTML to perform common tasks such as displaying an array of items in the UI, hiding and showing elements conditionally, styling HTML elements based on certain conditions, and more.
The very first thing we want to introduce is the concept of modules. Modules are AngularJS’s way of packaging relevant code under a single name. For someone coming from a Java background, a simple analogy is to think of modules as packages.
An AngularJS module has two parts to it: