AngularJS MVC Architecure
MVC stands for model view controller. It is a software design pattern for developing web applications. It is very popular because it isolates the application logic from the user interface layer and supports separation of concerns. The controller receives all requests for the application and then works with the model to prepare any data model by the view. The view then uses the data prepared by the controller to generate a final presentable response. The MVC abstraction can be graphically represents as follows
It is responsible for managing application data. It responds to the request from view and to the instructions from controller to update itself.
It is responsible for displaying all data or only a portion of data to users. It also specifies the data in a particular format triggered by the controller’s decision to present the data.
It is responsible to control the relation models and views. It responds to user input and performs interactions on the data model objects. The controller receives input, validates it, and then performs business operations that modify the state of the data models.
- Scope is passed as first argument to controller during its constructor definition.
- $scope.firstName and $scope.lastName are the models.
- We have set values to models which will be reflected in the application module whose controller is myController.