Skip to content

Instantly share code, notes, and snippets.

@ronapelbaum
Created July 19, 2016 07:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ronapelbaum/110b28e47ff358f1d2a571659f627acb to your computer and use it in GitHub Desktop.
Save ronapelbaum/110b28e47ff358f1d2a571659f627acb to your computer and use it in GitHub Desktop.
angular circular dependency
angular.module("app", [])
.service('A', function(B) {
this.data1 = 'a';
this.foo = function() {
console.log('A.foo:', this.data1, B.data2);
}
})
.service('B', function(A) {
this.data2 = 'b';
this.foo = function() {
console.log('B.foo:', A.data1, this.data2);
}
})
.run(function(A, B) {
A.foo();
B.foo();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment