Alexe Bogdan
Web Developer, JavaScript Lover, User Experience Professional, working in the web and mobile application development industry.
Model–view–controller (MVC) is a software architectural pattern for implementing user interfaces. It divides a given software application into three interconnected parts, so as to separate internal representations of information from the ways that information is presented to the user.
Model
The classes which are used to store and manipulate state, typically in a database of some kind.
View
The user interface bits (in this case, HTML) necessary to render the model to the user.
Controller
The brains of the application. The controller decides what the user's input was, how the model needs to change as a result of that input, and which resulting view should be used.
(Past)
Browser
Server
HTTP Request
HTTP Response
HTML
+
JavaScript
V
M
C
Dispatcher
Browser
Server
M
V
SPA HTML5 - JS
Static content
RESTful Endpoints
Event publisher
JSON - REST
Web Sokets
Request / response
(Present)
C
A single-page application (SPA), also known as single-page interface (SPI), is a web application or web site that fits on a single web page with the goal of providing a more fluid user experience akin to a desktop application.
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<title>Angular app</title>
<script src="path/to/angular.js"></script>
<script src="app.js"></script>
</head>
<body ng-controller="MyCtrl">
<p>Hello {{name}}!</p>
<input type="text" ng-model="name">
</body>
</html>
//app.js
angular
.module('myApp', [])
.controller('MyCtrl', function($scope){
$scope.name = 'World';
});
By Alexe Bogdan
About MVC Pattern and how to apply it on client-side
Web Developer, JavaScript Lover, User Experience Professional, working in the web and mobile application development industry.