AngularJS

Angular MVC

Introduction#

In AngularJS the MVC pattern is implemented in JavaScript and HTML. The view is defined in HTML, while the model and controller are implemented in JavaScript. There are several ways that these components can be put together in AngularJS but the simplest form starts with the view.

The Static View with controller

mvc demo

Hello World

Controller Function Definition

var indexController = myApp.controller("indexController", function ($scope) {
    // Application logic goes here
});

Adding information to the model

var indexController = myApp.controller("indexController", function ($scope) {
    // controller logic goes here
    $scope.message = "Hello Hacking World"
});

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow