Created
October 3, 2014 17:20
-
-
Save joshfinnie/a7eb03a45f571ffc425d to your computer and use it in GitHub Desktop.
Interesting way to inject underscore into Angular.js
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 | |
}); | |
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