Chapter 18Controllers
Controllers create a framework to promote code reusability and testability. They are the basic building blocks of an Angular application. In previous chapters, we covered data binding and directives. We briefly touched on Angular controllers at the end of Chapter 16. In this chapter, we’re going to cover controllers in greater detail. We’ll discuss what they are and what purpose they serve; we will then cover some syntax issues, best practices, and examples.
Like everything related to Angular, it is important to remember that controllers are just JavaScript functions. These functions are used to create a new Angular (or scope) context and are bound to sections of HTML markup. A controller provides a place to put application ...
Get Full Stack JavaScript Development With MEAN now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.