12 Oct 2018

AngularJS Modules

What are AngularJS Modules?

Basically modules define an application in AngularJS which is also a container for controllers as well as different parts of an application.


How can we create a module in AngularJS?

AngularJS has a predefined function “angular.module” which is basically used to create a module in AngularJS.


Syntax : 

<div ng-app=”NewModule”>

// Statements …………


var app = angular.module (“NewModule”, []);


Let us understand by a simple example.


For Example : 

<div ng-app=”NewModule” ng-controller=NewController>
{{ userName  + ” ” + password  }}

var app = angular.module(NewModule, []);
app.controller(NewController, function($scope) {
$scope.userName = “”;
$scope.password = “admin”;


Output :- admin

Angular JS Training

In Just 4 Days
Enroll Now