I only worked with 1 factory in angular, but now that my project has become too large, I want to split the file into separate factories.
My plants are as follows:
angular.module('factories')
.factory('auth', ['$http', '$state', '$window',
function($http, $state, $window) {
var auth = {};
......
return auth;
Userfactory:
angular.module('factories')
.factory('userFactory', ['$http', '$state', '$window',
function($http, $state, $window) {
var userFactory = {};
return userFactory;
I insert them into my controllers:
angular.module('controllers')
.controller('UserCtrl', ['$scope', '$state', 'auth', 'userFactory', 'Facebook',
function ($scope, $state, auth, userFactory, Facebook) {
However, I get the following error:
Error: [$ injector: unpr] http://errors.angularjs.org/1.4.7/ $ injector / unpr? p0 = userFactoryProvider% 20% 3C-% 20userFactory% 20% 3C-% 20UserCtrl
I also load my factories:
angular.module('factories', []);
And I enter the factories in app.js:
var app = angular.module('eva', ['ui.router', 'ngMaterial', 'ngMessages',
'controllers', 'factories', 'ngAnimate', '720kb.socialshare',
'angular-loading-bar', 'angular-svg-round-progress', 'pascalprecht.translate',
'facebook']);
What is the correct way to work with multiple factories?