Angularjs in Hindi Modules




AngularJS मे एक Module मे Controller, Service, Filters, Instructions, Factories आदि होते है. जैसे किसी Application के विभिन्न Parts का एक Container होता है ऐसे ही AngularJS मे एक ही Module के तहत कुछ Javascript की Functionality को एक साथ Group कर सकते है.

Angularjs मे आप एक Module से अपने Controllers, Services, Filters, Instructions आदि को Defined कर सकते है जो पूरे Module मे Accessible होते है.

एक Module को AngularJS द्वारा किसी Application को Bootstrap के लिए उपयोग मे लाया जा सकता है. Ng Application Instructions के लिए Module Name Pass करके हम इस Module को Application के मुख्य Entry Point के रूप मे Load करने के लिए AngularJS को Inform कर सकते है.

Module को अलग .js Files और Names के रूप मे module.js File मे Defined किया जाता है.


var mainApp = angular.module("mainApp", []); 


For Example

<!DOCTYPE html>
<html>
   <head>
      <title>Angular Modules Example</title>
      <script src = 
         "https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js">
      </script>
   </head>
   <body>
      <div ng-app="myApp" ng-controller="myCtrl">
         {{ firstName + " " + lastName }}
      </div>
      <script>
         var app = angular.module("myApp", []);
         app.controller("myCtrl", function($scope) {
            $scope.firstName = "Ali";
            $scope.lastName = "Khan";
         });
      </script>
   </body>
</html>

Output