Skip to content

Instantly share code, notes, and snippets.

@russellf9
Created May 6, 2014 20:15
Show Gist options
  • Save russellf9/6b08ca9210405daa0a41 to your computer and use it in GitHub Desktop.
Save russellf9/6b08ca9210405daa0a41 to your computer and use it in GitHub Desktop.
'use strict';
/*
* A Service which injects either a Mock or Live Service to implement the CRUD AJAX Calls
*
* For reference
* See: http://phonegap-tips.com/articles/conditional-dependency-injection-with-angularjs.html
*
*/
angular.module('myApp')
.service('routeservice', [ '$injector', function ( $injector ) {
var environment = 'DEV';
//var environment = 'LIVE';
if (environment === 'DEV') {
return $injector.get('mockeventservice');
} else {
return $injector.get('liverouteservice');
}
}]);
@russellf9
Copy link
Author

I thought this was cool, using conditional injection!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment