Modules in AngularJS
- makes code maintainable and testable
- dependencies between modules can be defined
CREATING MODULE
var myapp = angular.module('<module-name>', <dependencies>);
Example : myapp.js
var myapp = angular.module('module1', []);
USING MODULE
Example. To run given module when document loads
<html ng-app="module1">
<head>
<link rel="stylesheet" type="text/css" href="bootstrap.min.css" />
</head>
<body>
<script type="text/javascript" src="angular.min.js"> </script>
<script type="text/javascript" src="myapp.js"> </script>
</body>
</html>
No comments:
Post a Comment
Note: only a member of this blog may post a comment.