Created
November 1, 2014 10:57
-
-
Save skusunam/9d3f89912335587b98fc to your computer and use it in GitHub Desktop.
How to use Global Dependencies in AngularJS without breaking DI
This file contains hidden or 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 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