Last active
December 31, 2015 15:49
-
-
Save SelrahcD/8009538 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var module = angular.module('Test', []); | |
module.service('TestService', ['ServiceA', function(serviceA) { | |
}]); | |
module.service('ServiceA', function() { | |
// First implementation of Service A | |
}); | |
module.service('ServiceABis', function() { | |
// Second implementation of Service A | |
}); | |
Every time ServiceA is needed as a dependecy inject ServiceABis instead of ServiceA, for instance in TestService. |
var module = angular.module('Test', []);
module.service('TestService', ['ServiceA', function(serviceA) {
}]);
var ServiceA = window.location.search === '?IWantServiceABis' ? function() {
// Second implementation of Service A
} : function() {
// First implementation of Service A
};
module.service('ServiceA', ServiceA);
@ithinkdancan The issue came up when I was working without an Internet access and needed to request upon an API. I wanted to make a service returning fake data.
@christophehurpeau I think this would make our good friends cry too...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
why would you not want serviceA?