Skip to content

Instantly share code, notes, and snippets.

@skusunam
Created November 1, 2014 10:57
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 skusunam/9d3f89912335587b98fc to your computer and use it in GitHub Desktop.
Save skusunam/9d3f89912335587b98fc to your computer and use it in GitHub Desktop.
How to use Global Dependencies in AngularJS without breaking DI
var underscore = angular.module(‘underscore’, []);
underscore.factory(‘_’, function() {
return window._; //Underscore must already be loaded on the page
});
var app = angular.module(‘app’, ['underscore']);
app.controller(‘MainCtrl’, ['$scope', '_', function($scope, _) {
init = function() {
_.keys($scope);
}
init();
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment