I am trying to load my own module, it worked with first module but facing error when I tried to add another module. See below files:
app.js
var gcApp = angular.module('gcApp', [
'ui.router',
'gcApp.controllers',
'gcApp.services'
]);
gcApp.config(function ($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/home');
$stateProvider
.state('home', {
url: '/home',
templateUrl: 'views/home.html'
})
.state('farmer-home', {
url: '/farmer-home',
templateUrl: 'views/farmer-home.html',
//controller: 'farmerCtrl'
})
.state('login', {
url: '/login',
templateUrl: 'views/login.html',
controller: 'loginCtrl'
});
});
controller.js
'use strict';
/* Controllers */
var controllers = angular.module('gcApp.controllers', [
'login-controller',
'farmer-controller'
]);
farmer-controller.js
'use strict';
var farmerController = angular.module('farmer-controller', []);
farmerController.controller('farmerCtrl', function ($scope, $rootScope, $location) {
console.log("Farmer controller..");
});
service.js
'use strict';
/* Services */
var services = angular.module('gcApp.services', [
'login-service',
'farmer-service'
]);
farmer-service.js
'use strict';
var farmerService = angular.module('farmer-service', []);
farmerService.service('FarmerManagementService', function ($http, $rootScope) {
console.log("FarmerManagementService");
});
At the first there was only login-controller in controllers and login-service in services. It is running smoothly. But when I added farmer-controller in controllers and farmer-service in services it is showing the above error. I have no idea why this is happening.
Conceptually I have added farmer-controller module into controllers and for service. So I am wondering why it is failed to load every time. At which point I am doing the wrong thing.
Angular version I am using is 1.5.6