Some time in angular we face a error with name Circular Dependency, actually angular/ionic throw this error when we inject factory-1/service-1 in factory-2/service-2 and in factory-2/service-2 inject factory-1/service-1 like :
We can resolve this error using $injector , like :
app.factory('factory1', function (factory2) {
// Here is your other code
});
app.factory('factory2', function (factory1) {
// Here is your other code
});
We can resolve this error using $injector , like :
app.factory('factory1', function (factory2) {
// Here is your other code
});
app.factory('factory2', function ($injector) {
var factory1 = $injector.get('factory1'); // Here is your factory1
// Here is your other code
});
- 3:01 PM
- 0 Comments