3) MVC Architecture
3) MVC Architecture
Advanced Technologies
MVC Architecture 2
Model
• The Model component deals with the data of the application.
• This component is responsible for managing the data, logic, and rules of the
application.
View
• Handles the User Interface(UI). This component typically consists of the html,
css, and static js files.
• The view component is used to attach and trigger user events but the event
handling comes under the domain of the controller .
Controller
• The primary responsibility of a controller is to handle the events triggered by
user input and also acts as a mediator between the view and model.
• In other words, the controller contains client-side specific logic.
• The controller provides various functions based on events that can be
triggered and then contacts the model for reading/updating data and presents
the new information to view component to be shown to the user.
Some of the most popular and extensively used MVC frameworks are listed
below.
– Ruby on Rails
– Django
– CherryPy
– Spring MVC
– Catalyst
– Rails
– Zend Framework
– Fuel PHP
– Laravel
– Symphony
• JavaScript frameworks categorizing into the front end, back end and
testing ones.
– Front End JavaScript framework
• React JS
• Vue Js
• Angular JS
• Ember JS
• Preact JS
• Svelte JS
• It extends the HTML into the application and interprets the attributes to
perform data binding.
• <script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js">
</script>
AngularJS extends HTML with ng-directives.
• The ng-app directive defines an AngularJS application.
• The ng-model directive binds the value of HTML controls (input, select,
textarea) to application data.
• The ng-bind directive binds application data to the HTML view.
November 23, 2024
AngularJS directive 14
<html>
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></
script>
<body>
<div ng-app="">
<p>Input something in the input box:</p>
<p>Name: <input type="text" ng-model="name"></p>
<p ng-bind="name"></p>
</div>
</body>
</html>
• AngularJS will resolve the expression, and return the result exactly where
the expression is written.
• Data binding in AngularJS is the synchronization between the model and the
view.
• When data in the model changes, the view reflects the change, and when
data in the view changes, the model is updated as well.
• This happens immediately and automatically, which makes sure that the
model and the view is updated at all times.
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js">
</script>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
{{ firstName + " " + lastName }}
</div>
<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
$scope.firstName = "Ajith";
$scope.lastName = “Kumar";
});
</script>
</body> </html> November 23, 2024
How to add controller to a module
22