I got following code:
define(function() {
var core = function() {};
var module;
core.prototype.module = {
setModule: function(name) {
this.module = name;
module = name;
}
};
core.prototype.sandbox = {
getModules: function() {
// will throw undefined
console.log(this._module);
// will maybe not throw an error?
console.log(modules);
}
};
});
define(['kernel'], function(Kernel) {
var sampleCore = new Core();
sampleCore.setModule('test');
sampleCore.getModules();
});
As you see I can’t access the other namespace with this approach. Is there another way to access this.module somehow?
Regards
How about setting a parameter for the object?: