Closed csbenjamin closed 9 years ago
For example, the https://github.com/fraywing/textAngular component. There, there is a module textAngular that have a value taTools which is a object. Still in this module, there is a config block with this code:
// clear taTools variable. Just catches testing and any other time that this config may run multiple times...
angular.forEach(taTools, function(value, key){ delete taTools[key]; });
This module requires a module textAngularSetup, which have a run block that fills the taTools object.
As textAngularSetup is a dependence of textAngular, it needs to be executed first. But after it fills the taTools object, the config block of textAngular module will clear the taTools object, which is not expected.
@csbenjamin sorry for delay but it has been a horrible 2 weeks of deadlines for me. Would you consider a pull request? It would be great if you add a unit test to it as well.
However, I do realise that angularAMD's unit test is a bit convoluted so I will try to add the unit test if you do the first part. That will allow me to take a closer look as well.
Many thanks.
@marcoslin I can do a pull request. But tell me if there is a reason for alternate_modules = {};
is inside the while.
I created alternate_modules
so that module can be returned within a ngload
but clear it after it has been loaded. For example:
myModule.js
angular.modue('myModule', []);
...
var mod = angular.module('myModule');
mod.factory(...);
In this case, var mod
needs to be populated but after myModules.js
has been loaded, call to angular.module('myModule')
should return undefined
. This was done mostly to catch the intermodule dependencies where a module is created in one file and optional features are added by another.
So, we can put alternate_modules = {};
after the loops instead inside them. I'm asking about this because now we will have two loops. One for config blocks and another for run blocks. In my code above I put alternate_modules = {};
inside the loop of run blocks. But I think we can put outside the loops. Am I right?
@marcoslin I did a pull request without test. here: https://github.com/marcoslin/angularAMD/pull/125
If I have a module A and a module B and the run block of A needs something executed in config block of B and the run block of B needs something executed in config block of A, the current angularAMD version will not work. The changes in AngularAMD.prototype.processQueue bellow fixes this