Please refer to the following article for the basics:

In this blog we will see,

What is Module and how to create it?

  1. Module is a kind of Main () method in AngularJS which contains controllers, services, directives etc.
  2. Module in AngularJS can be created by using following syntax.
  3. Module is used with ng-app.

A Module can be dependent on another module like ngRoute, ui.bootstrap.

What is a controller and how to create a controller?

  1. Controller is a function which defines the data for view to display.
  2. It can retrieve data from the database by calling a service. Controller is used with ng-controller.
  3. The syntax to create controller is,

$scope is an object to which the data is attached and it is then retrieved and displayed.

Here message is attached to $scope object. So in the Html page which is using this controller by using double curly braces {{message}} the message will be displayed.

The controller needs to be registered with a module like this



Complete Code for Creating Module, Controller and registering Controller with Module is,

  1. varmyApp = angular.module("myModule", [])
  2. varmyController = function ($scope) {
  3. $scope.message = "Welcome to angular JS";
  4. };
  5. myApp.controller("myController", myController);
or
  1. varmyApp = angular
  2. .module("myModule", [])
  3. .controller("myController", function ($scope) {
  4. $scope.message = "Welcome to angular JS";
  5. });
Steps to Create Application,

Step 1

Download Angular.JS file from AngularJS.org.

Step 2

Create a website in Visual Studio. Add Angular.js file in it.

Find the below screenshots for reference.