Donmclean
6/6/2016 - 11:50 AM

Properly integrate non-AngularJS libraries in your AngularJS application

Properly integrate non-AngularJS libraries in your AngularJS application

function LodashFactory($window) {  
  if(!$window._){
    // If lodash is not available you can now provide a
    // mock service, try to load it from somewhere else,
    // redirect the user to a dedicated error page, ...
  }
  return $window._;
}

// Define dependencies
LodashFactory.$inject = ['$window'];

// Register factory
yourModule.factory('_', LodashFactory);