Skip to content

Instantly share code, notes, and snippets.

@Exlord
Last active August 29, 2015 14:22
Show Gist options
  • Save Exlord/1fc5cd3f3c8d2eccdb5d to your computer and use it in GitHub Desktop.
Save Exlord/1fc5cd3f3c8d2eccdb5d to your computer and use it in GitHub Desktop.
Fixing Duplicate $browser provider with multiple app bootstrap in Angular 1.3
var __browser = null;
(function (angular) {
var origMethod = angular.module;
angular.module = function (name, reqs, configFn) {
var module = origMethod(name, reqs, configFn);
///////////////////// override the browser service
module.config(['$provide', '$compileProvider', '$routeProvider', function ($provide, $compileProvider, $routeProvider) {
$provide.provider('$browser', function $BrowserProvider() {
this.$get = ['$window', '$log', '$sniffer', '$document',
function ($window, $log, $sniffer, $document) {
return __browser;
}];
});
}]);
if (__browser == null) {
__browser = angular.injector(['ng']).get('$browser');
}
return module;
};
})(angular);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment