Creating a Module:-
Angular JS function angular.module का उपयोग करके एक मॉड्यूल बनाया जाता है।
Adding a controller:-
Add a controller to your application, and refer to the controller with the ng-controller directive.
Modules and Controller in files:-
एंगुलर जेएस एप्लिकेशन में मॉड्यूल और controllers को जावास्क्रिप्ट फाइलों में रखना आम बात है।
<!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 = “Akhilesh”;
$scope.lastName = “Sir”;
});
</script>
</body>
</html>
Creating a Module:-
A module is created using the Angular JS function angular.module.
Adding a controller:-
Add a controller to your application, and refer to the controller with the ng-controller directive.
Modules and Controller in files:-
It is common in Angular JS applications to place modules and controllers in JavaScript files.
<!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 = “Akhilesh”;
$scope.lastName = “Sir”;
});
</script>
</body>
</html>