【问题标题】:Sharing data between two modules MeanJs not working在两个模块 MeanJs 之间共享数据不起作用
【发布时间】:2015-09-04 11:55:08
【问题描述】:

我已经调查了这个问题几个小时,但没有成功。我肯定在这里遗漏了一些东西。

我希望能够在我创建的两个模块之间共享信息。所以基本上第一个模块是 MeanJs 附带的用户模块,另一个模块是使用 yo meanjs 生成器生成的。看看下面我的代码。

这是产品模块:

angular.module('products').factory('Productplan', [
   function() {
    return {
        someMethod: function() {
            return "I am Working!";
        }
    };
}

]);

这是用户模块:

angular.module('users').controller('AuthenticationController', ['$scope', 'Productplan',
function($scope, Productplan) {
    console.log(Productplan.someMethod());
}

]);

这是这个问题产生的错误:

Error: [$injector:unpr] Unknown provider: ProductplanProvider <- Productplan

提前致谢

【问题讨论】:

    标签: angularjs meanjs


    【解决方案1】:

    更改您的用户模块
    angular.module('users')
    

    angular.module('users',['products'])
    

    【讨论】:

    • 我试过了,当我添加 ['products'] 时应用程序路由不起作用,它会将您重定向到主页。我的意思是它应该可以工作,但我开始认为在 meanjs 中,事情可能会有所不同。
    猜你喜欢
    • 2015-10-08
    • 2017-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-23
    • 2017-10-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多