Skip to content

Instantly share code, notes, and snippets.

@ronapelbaum
Last active July 4, 2016 20:14
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/9e1c65794612c12924b603aec947f4e4 to your computer and use it in GitHub Desktop.
Save ronapelbaum/9e1c65794612c12924b603aec947f4e4 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