Reputation: 71
We created dynamic module injection with requirejs in our angular application. Now we have created parameter instances of function for each module separately (commonModule, usersModule). How can we possible to make it dynamic for module dependency injection in requirejs and angularjs?
var _moduleFiles = ["common/module", "user/module"];
require(_moduleFiles, function(commonModule, usersModule) {
var app = angular.module('Myapp', [commonModule, usersModule]);
});
Upvotes: 0
Views: 194
Reputation: 71
I have investigated about this issue and can found out that it may not be possible to implement dynamic module injection in requirejs.
Dynamic code loading (done in AMD systems via require([], function (){})) is a basic requirement. CJS talked about it, had some proposals, but it was not fully embraced. Node does not have any support for this need, instead relying on the synchronous behavior of require(''), which is not portable to the web.
Upvotes: 1