Last active
August 29, 2015 14:22
-
-
Save Exlord/1fc5cd3f3c8d2eccdb5d to your computer and use it in GitHub Desktop.
Fixing Duplicate $browser provider with multiple app bootstrap in Angular 1.3
This file contains 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 __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