You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.1 KiB
1.1 KiB
AngularJS - Advanced
Lesson Objectives
- Explain what dependencies do
- Create a module and inject it into another one
Explain what dependencies do
- We can group functionality together into different modules
- You can have multiple ng-apps on your page, each with specific functionality
- Modules can be dependent on other modules
- Very large modules can be broken out into smaller sub modules, grouped by functionality
Create a module and inject it into another one
In this example, imagine we have a very large module for our "store" app. Since we don't want one very large file, we can break it apart into many smaller files.
This first file will be module just for the store directives
file: js/store-directives.js
const app = angular.module('store-directives', []);
app.directive('productTitle', function(){
// directive stuff
});
app.directive('productGallery', function(){
// directive stuff
});
We can now include the module for our directives in the store as a whole
file: js/store.js
const app = angular.module('store', ['store-directives']);