• Recipes with Angular.js

  • Menu
  • Search
  • Home
  • Introduction
  • Controllers
    • Assigning a Default Value to a Model
    • Changing a Model Value with a Controller Function
    • Encapsulating a Model Value with a Controller Function
    • Responding to Scope Changes
    • Sharing Models Between Nested Controllers
    • Sharing Code Between Controllers using Services
    • Testing Controllers
  • Directives
  • Filters
  • Using Forms
  • Consuming External Services
  • Urls Routing and Partials
  • Common User Interface Patterns
  • Backend Integration with Ruby on Rails
  • Backend Integration with Node Express

Controllers

Controllers in Angular provide the business logic to handle view behavior, for example responding to a user clicking a button or entering some text in a form. Additionally, controllers prepare the model for the view template.

As a general rule, a controller should not reference or manipulate the DOM directly. This has the benefit of simplifying unit testing controllers.

Table of Contents

  1. Controllers
  2. Assigning a Default Value to a Model
  3. Changing a Model Value with a Controller Function
  4. Encapsulating a Model Value with a Controller Function
  5. Responding to Scope Changes
  6. Sharing Models Between Nested Controllers
  7. Sharing Code Between Controllers using Services
  8. Testing Controllers

Maintained by Frederik Dietz

All content licensed with Creative Commons