AngularJS module is nothing but a container of all angular components like controller, services, directive, filter, config etc
What is Module
Let me explain why module is required in AngularJS. In .NET console application there is a main method and what main method does is, it’s an entry point of application. It is the same as angular module and is an entry point. Using module we can decide how the AngularJS application should be bootstrapped.
We can create a simple module using the following code.
var myApp = angular.module(‘myModuleApp’,[]);
In the above code myModuleApp is the module name and if this module is dependent on other modules we can inject in “[]”.
What is Controller?
Controller is a JavaScript constructor function which controls the data. I am not going to cover what are the types of functions in this article but let me give some brief information about constructor function. In constructor function when we call that function that function creates a new object each time.
Let’s make a controller.
myApp.controller(‘myController’, function($scope)
{
});