Angularjs Examples

AJS Examples


AngularJS MVC Architecture

MVC stands for Model View Controller which is very popular design pattern in web world. It helps you to organise your application in three different layers and isolate the business logic from its presentation.

  • Model - represent current state and data of your application
  • View - responsible to display/show the data
  • Controller - responsible to controls the relation between Models and Views.

Now let's understand how these three component works in AngularJS MVC Architecture step by step.

Model

in AngularJS, model consists of all premitive data type such as integer, string and boolean and complex type in form of object. In simple word model is just a plain javascript object. But you can build your model from any database like Sql Server or Mysql or from JSON file. In below given syntax $scope is an object, customer is variable which is added to scope object.

Syntax

View

in AngularJS, view is the DOM elements which is used to display data. To display data from controller, use expression in view. Since AngularJS supports two-way data binding any changes in model data, view will update automatically.

Syntax

Controller

in AngularJS, controller provide great control over view and model in order to fatch the data as per request and display in the view. Most important thing here is your model is lives inside the controller.

Syntax

AngularJS MVC Example