angualrjs - 工厂没有正确注入,得到错误

时间:2016-11-11 07:01:47

标签: angularjs angular-factory

在创建modules服务后,我为factory创建了单独的文件。后来我试图在我的控制器中使用,但我得到一个错误:

Unknown provider: authFactoryProvider <- authFactory <- mainController

这里有什么问题?

我的模块文件:

(function(){

    "use strict";

    var ngModules =  ['ui.router'];

    var appModules = ['meanOffice.factories','meanOffice.controllers', 'meanOffice.directives'];

    var modules = [];

    modules = modules.concat( ngModules );
    modules = modules.concat( appModules );

    angular.module('meanOffice.factories',[]);
    angular.module('meanOffice.controllers', []);
    angular.module('meanOffice.directives', []);

    angular.module( 'meanOffice', modules );

})();

我的工厂:

(function(){

    "use strict";
     // alert('hi'); -works 

    angular.module('meanOffice.factories')
        .factory('authFactory', function($scope){

            var authFactory = {};


            authFactory.init = function(){

                console.log(' init called ');

            }

            return authFactory;

        })

})();

0 个答案:

没有答案