javascript - Creating angularjs modules -


i looking @ source-code of angular-flash below: https://github.com/gtramontina/angular-flash/blob/master/angular-flash.js

can explain me on how creating flash module

(function (root, factory) {     if (typeof module !== 'undefined' && module.exports) {         // commonjs         module.exports = factory(root, require('angular'));     } else if (typeof define === 'function' && define.amd) {         // amd         define(['angular'], function (react, angular) {             return (root.angularflash = factory(root, angular));         });     } else {         // global variables         root.angularflash = factory(root, root.angular);     } }(this, function (window, angular) {     return angular.module('flash', []); })); 

what not understanding argument factory being received , root.angularflash variable? how create angular module flash?

i don't see anywhere angularflash variable used?

(function (root, factory) {     if (typeof module !== 'undefined' && module.exports) {         // commonjs         module.exports = factory(root, require('angular'));     } else if (typeof define === 'function' && define.amd) {         // amd         define(['angular'], function (react, angular) {             return (root.angularflash = factory(root, angular));         });     } else {         // global variables         root.angularflash = factory(root, root.angular);     } }(this, function (window, angular) {     return angular.module('flash', []); })); 

if @ iife @ bottom it's calling passing anonymous function second argument named factory defined angular module flash:

factory = function (window, angular) {     return angular.module('flash', []); } 

so when factory invoked it's defining module named flash.


Comments