Chapter 5. The Controller in Detail

The controller is where your business logic lives.  To define business logic, let's say it's the layer between your UI and your data store, and any algorithms needed to support that. What a controller isn't, is a place to put DOM modification code. The controller doesn't know about the DOM, and should be decoupled from the view. Why is it then that other JavaScript frameworks want you to do exactly what I'm telling you not to do? I think the answer lies along the lines of "there's nowhere else to put it." With AngularJS, we DO have a place to put it, and not a controller (it's a directive, which we will explore later).

Adding Functionality to Our Controller

Now that we have a nice view, we need to add some ...

Get Developing an AngularJS Edge now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.