I have a couple of modules that I want to instantiate the object from a string.
This is usually easy when classes/objects etc are on the global scope window
new window["MyClass"]()
With require JS the modules aren't in the window scope and they're not on this if within a class.
Do you know what scope I require?
define(['testclassb'], function(TestClassB) {
var TestClassA, testclassa;
TestClassA = (function() {
function TestClassA() {
console.log("A");
new this["TestClassB"](); #errors with undefined function
new window["TestClassB"](); #errors with undefined function
new TestClassB(); #works fine
}
TestClassA.prototype.wave = function() {
return console.log("Wave");
};
return TestClassA;
})();
testclassa = new TestClassA();
return testclassa.wave();
});