如何在Javascript中插入模块?

如何在Javascript中插入模块?,javascript,jquery,angularjs,design-patterns,Javascript,Jquery,Angularjs,Design Patterns,我正在使用模块模式,现在我想知道是否可以像AngularJs一样将一个模块注入另一个模块 下面是我尝试过的示例代码 module.js var AnotherModule = (function () { function AnotherModule() { this.anotherFunction = function () { alert('Inside another Module'); } } return

我正在使用模块模式,现在我想知道是否可以像AngularJs一样将一个模块注入另一个模块

下面是我尝试过的示例代码

module.js

var AnotherModule = (function () {

    function AnotherModule() {
        this.anotherFunction = function () {
            alert('Inside another Module');
        }
    }
    return AnotherModule;

})(window);

var AnotherModule = new AnotherModule();

var Module = (function (window, AnotherModule) {

    function Module(AnotherModule) {

        var privateMethod = function() {

        }

        this.getName = function (brand) {
            console.log('Inside get Name');
            console.log(AnotherModule);
        }

    }
    return Module;

})(window, AnotherModule);


var module = new Module();
module.getName();

对实例和定义使用相同的变量名没有帮助!例如,当您执行
(窗口,AnotherModule)时
你是在试图将定义或你之前创建的实例传递给那个IILife吗?是的,但为什么不使用AngularJs呢?我非常依赖SEO,据我所知,我们无法使用AngularJs实现这一点。可能想重新审视这个假设。