بلاگ

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.

Syntax :

<div ng-app=”NewModule”>

// Statements …………

</ div>

<لپي>
var app = angular.module (“NewModule”, []);
</ اسڪرپٽ>

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”;
})؛
</ اسڪرپٽ>

Output :- angularjs@doc.com admin

Angular JS Training

In Just 4 Days
هاڻي وڌو

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