This is a continued series of tutorials. Please refer to intro part here
Modules are used for organizing the application. Means what? It means that various parts related to your application are defined in the Modules. Various parts like Controllers , Services etc.
Though we can define the Modules in same page but the recommended practice is to keep it in seperate JS file and refer it wheverever we are going to use it.
app = angular.module("myApplication", );
In above example Angular checks for
ng-app directive through the DOM. The container which has this directive becomes the host of Angular. The
app variable will have full access to angular child objects.
NOTE: It is highly recommended that we declare angular library at the
head tag or at the start of the
body tag. Once Angular is initialized then it will compile
Once the module is added then we can add Controllers, Custom Directives, etc.
Angular modules are more like structuring your code at a common place. Angular Controllers can only be called if module is present.
Next we will see Angular controllers.