bing
Flat 10% & upto 50% off + 10% Cashback + Free additional Courses. Hurry up
×
UPTO
50%
OFF!
Intellipaat
Intellipaat

What is AngularJS Modules?

Modules in AngularJS define an application. These are used to divide the logic such as controllers, services, application etc. and keep the code clean. It is define in separate js file. Controllers always belong to a module.

Example

<!DOCTYPE html>

<html>

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>

<body>

<div ng-app="intellipaatApp" ng-controller="intellipaatCtrl">

{{ first + " " + second }}

</div>

<script>

var app = angular.module("intellipaatApp", []);  // Application Module

app.controller("intellipaatCtrl", function($scope) {  // Controller Module

$scope.first = "Hello";

$scope.second = "Intellipaat";

});

</script>

</body>

</html>

Output

Hello Intellipaat

 

Modules and Controllers in Files

e.g.

<!DOCTYPE html>

<html>

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>

<body>

<div ng-app="intellipaatApp" ng-controller="intellipaatCtrl">// User Module

{{first + " " + second}}

</div>

<script src="intellipaatApp.js"></script>

<script src="intellipaatCtrl.js"></script>

</body>

</html>

Output

Hello Intellipaat

In this example intellipaatApp.js have an application module definition and intellipaatCtrl.js have the controller

Previous Next

Download Interview Questions asked by top MNCs in 2019?

"0 Responses on AngularJS Modules"

    100% Secure Payments. All major credit & debit cards accepted Or Pay by Paypal.
    top

    Sales Offer

    Sign Up or Login to view the Free AngularJS Modules.