12 октомври 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.


<div ng-app=”NewModule”>

// Statements …………

</ Div>

var app = angular.module (“NewModule”, []);
</ Script>

Let us understand by a simple example.

Например :

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

var app = angular.module(NewModule, []);
app.controller(NewController, function($scope) {
$scope.userName = “angularjs@doc.com”;
$scope.password = “admin”;
</ Script>

Output :- angularjs@doc.com admin

Angular JS Training

In Just 4 Days
Регистрирайте се сега

GTranslate Your license is inactive or expired, please subscribe again!