|
Answer» AngularJS Controller As we knows now that Applications in AngularJS are controlled by the controllers. As we also know there is immediate synchronization between the Model and the View. And controller can be COMPLETELY separated from the view and will concentrate on Model data. And with the data binding in AngularJS the view will reflect CHANGES made in controller. AngularJS controllers control the data of AngularJS applications.
 AngularJS controllers are regular JavaScript Objects. The ng-controller directive defines the application controller. And controller is JavaScript object which is created by STANDARD JavaScript object constructor.
 Now i will give some details on the above example. AngularJS
application is defined by ng-app="myTestApp". And the application run inside the < div> TAG. And the ng-controller="myTestCtrl" attribute is and AngularJS directive which defines the controller.
And myTestCtrl function is a JavaScript function.
And AngularJs will invoke the controller witha $scope object.
In AngularJS $scope is application object which is owner of application variable and function.
Controller creates 2 properties in scope and these are EmployeeFirstName and EmployeeLastName.
And ng-model DIRECTIVES bind input fields to the controller properties.
|