Please refer to the following article for the basics:
In this blog we will see,
- What is module and what is a controller
- How to create a module and controller
- How it works
What is Module and how to create it?
- Module is a kind of Main () method in AngularJS which contains controllers, services, directives etc.
- Module in AngularJS can be created by using following syntax.
- 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?
- Controller is a function which defines the data for view to display.
- It can retrieve data from the database by calling a service. Controller is used with ng-controller.
- 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,
- varmyApp = angular.module("myModule", [])
- varmyController = function ($scope) {
- $scope.message = "Welcome to angular JS";
- };
- myApp.controller("myController", myController);
- varmyApp = angular
- .module("myModule", [])
- .controller("myController", function ($scope) {
- $scope.message = "Welcome to angular JS";
- });
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.




Join the conversation! Your thoughts help the community grow.