Here we have “Customer” controller which provides data via “CustomerName” and “CustomerCode” property and Add/ Update logic to save the data to database.
“Controllers” are simple javascript function which provides data and logic to HTML UI. As the name says controller they control how data flows from the server to HTML UI.
function Employee($scope) { $scope.FirstName = "Anupam"; $scope.EmployeeCode = "1001"; $scope.Add = function () { } $scope.Update = function () { } }
“ng-controller” is a directive.Controllers are attached to the HTML UI by using the “ng-controller” directive tag and the properties of the controller are attached by using “ng-model” directive. For example below is a simple HTML UI which is attached to the “Employee” controller via the “ng-controller” directive and the properties are binded using “ng-model” directive.
Manoj Bhatt
24-Feb-2016