inject jquery and underscore to angular js component
angularjs, javascript, jquery, underscore.js
Solution
based on @moderndegree's approach I have implemented the following code, I cannot say it is perfect but this way tester would know if it has jQuery dependency as `$window` is too generic object to inject.
'use strict';
(function () {
var app= angular.module('app');
//these are just references the instance of related lib so we can inject them to the controllers/services in an angular way.
app.factory('jQuery', [
'$window',
function ($window) {
return $window.jQuery;
}
]);
app.factory('Modernizr', [
'$window',
function ($window) {
return $window.Modernizr;
}
]);
app.factory('Highcharts', [
'$window',
function ($window) {
return $window.Highcharts;
}
]);
})();
Problem
I am using angularjs, underscore and jQuery in my new service: ``` myModule.factory('MyService', ['MyResource', function (MyResource) { .... // Here I make use of _ and $ }]); ``` How can I inject underscore or jQuery to the new service so I can be sure that _ is underscore and $ is jquery? I am looking for something like: ``` myModule.factory('MyService', [ 'underscore', 'jquery','MyResource', function (_, $, MyResource) { .... // Here I want to use $ and _ and be SURE that _ is underscore and $ is jquery }]); ```