Skip to content

Instantly share code, notes, and snippets.

@joshfinnie
Created October 3, 2014 17:20
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 joshfinnie/a7eb03a45f571ffc425d to your computer and use it in GitHub Desktop.
Save joshfinnie/a7eb03a45f571ffc425d to your computer and use it in GitHub Desktop.
Interesting way to inject underscore into Angular.js
var underscore = angular.module('underscore', []);
underscore.factory('_', function() {
return window._; //Underscore must already be loaded on the page
});
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