Using Controllers in AngularJS
The controllers primary purpose is to control the view model contained within the Angular scope. Controllers are used in AngularJS to: Set the initial state of Scope variables, which are then made available for the View to consume and interact with Add behavior to the Scope by two-way binding variables and declaring Scope functions Set up communications to and from the view and Model objects such as Services, brought in through Dependency Injection Angular invokes the controller with a $scope object. Any objects (or primitives) assigned to the scope become model properties. The role of controllers in Angular is to expose data to our view via $scope, and to add functions to $scope that contain business logic that enhances view behavior. A controller should contain only the business logic needed for a single view; presentation logic should remain within views and directives. Controllers are created by registering with an existing Angular Module. var app = angular