在创建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;
})
})();