Simple you can create module by using the AngularJS function angular.module.

<div ng-app=”myPro”>…</div>

<script>

var app = angular.module(“myPro”, []);

</script>

Application will run by using “myPro” parameter.

Now you can add controllers, directives, filters, and more, to your AngularJS application.

HTML:

<div ng-app=”myPro”>
<div>
{{ ‘World’ | greet }}
</div>
</div>

Script:

// declare a module
var myAppModule = angular.module(‘myPro’, []);
myAppModule.filter(‘greet’, function() {
return function(name) {
return ‘Hello, ‘ + name + ‘!’;
};
});

 Example:

<!DOCTYPE html>
<html ng-app=”myPro”>

<head>
<title> AngulaJS Module Example</title>
<script src=”//ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js”></script>
</head>

<body>

<div ng-controller=”myController”>

First Name: <input type=”text” ng-model=”first_name”><br>
Last Name: <input type=”text” ng-model=”last_name”><br>
<br>
Full Name: {{first_name + ” ” + last_name}}

</div>

<script>
var app = angular.module(“firstApp”, []);
app.controller(“myController”, function($scope) {
$scope.first_name = “PHP”,
$scope.last_name = “Developer”,
});
</script>

</body>
</html>

News Reporter
IT Software and web development, Core PHP, JavaScript, JQuery, HTML, CSS, CakePHP, Angularjs, Codeigniter etc.

Leave a Reply

Your email address will not be published. Required fields are marked *

error: