0

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

1
  • It was a silly mistake from my side. I forgot to add new js files in index.html Commented Sep 29, 2016 at 12:29

1 Answer 1

1

Change

var controllers = angular.module('gcApp.controllers', [
    'login-controller',
    'farmer-controller',
]);

to

var controllers = angular.module('gcApp.controllers', [
    'login-controller',
    'farmer-controller'
]);

and also

var services = angular.module('gcApp.services', [
    'login-service',
    'farmer-service',
    ]);

to

var services = angular.module('gcApp.services', [
    'login-service',
    'farmer-service'
    ]);

and try again. there should not be comma after last dependancy.

Sign up to request clarification or add additional context in comments.

1 Comment

I am sorry but commas has been removed before posting. I will update the question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.