×

Html & Html5

The World's best Software Development Study Portal

AngularJS Module


module is a container for the application controllers.
In AngularJS, a module defines an application. It is a container for the different parts of your application like controller, services, filters, directives etc




Step 1.Create a Module
var app = angular.module("myApp", []);

Step 2. Add a Controller
app.controller("myCtrl", function($scope) {
$scope.firstName = "IT training classes";
$scope.lastName = "gurgaon"; });





we can put the module and the controllers in JavaScript files or in external files like.
<script src="myApp.js"></script>
<script src="myCtrl.js"></script>
where
"myApp.js" contains an application module definition
"myCtrl.js" contains the controller:




myApp.js
var app = angular.module("myApp", []);
myCtrl.js
app.controller("myCtrl", function($scope) {
$scope.firstName = "IT training classes";
$scope.lastName = "gurgaon"; });

Note: Here"myApp" parameter refers to an HTML element in which the application will run.