1
votes

i am running out of ideas. AngularJs claims that there is a circular dependency in my project. I need someone to have a look on 4 eyes principel. All boils down to the following code...whenever i remove the HotelServices dependecy from BookingCtrl angular is fine. This wiring seems to cause a circular dependency. I dont see where!?

var app = angular.module('hopBooking', [
        'ngRoute',
        'hopBooking.services',
        'hopBooking.controllers'
    ]);

services.js

var app = angular.module('hopBooking.services', []);

app.service('HotelServices', ['HotelServices', function($scope, $rootScope, $http) {
    return {
        find: function(id) {
        // put here a http requests
        },
    };
}]);

controllers.js

var app = angular.module('hopBooking.controllers', []);

app.controller('BookingCtrl', function($scope, HotelServices) {});
1
You're trying to insert HotelServices as dependency of HotelServices: app.service('HotelServices', ['HotelServices', - Joao Polo
oh man. thats it. i was blind! Thanks! - Ugur Teker

1 Answers

1
votes

try to remove the auto-reference on HotelServices declaration:

app.service('HotelServices', function($http) {
    return {
        find: function(id) {
        // put here a http requests
        },
    };
});

and also, like @charlietfl said, removes the scope references