router-upgrade.umd.min.js 1.96 KB
/**
 * @license Angular v3.4.5
 * (c) 2010-2016 Google, Inc. https://angular.io/
 * License: MIT
 */
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("@angular/core"),require("@angular/router"),require("@angular/upgrade/static")):"function"==typeof define&&define.amd?define(["exports","@angular/core","@angular/router","@angular/upgrade/static"],factory):factory((global.ng=global.ng||{},global.ng.router=global.ng.router||{},global.ng.router.upgrade=global.ng.router.upgrade||{}),global.ng.core,global.ng.router,global.ng.upgrade.static)}(this,function(exports,_angular_core,_angular_router,_angular_upgrade_static){"use strict";function initialRouterNavigation(ngUpgrade,ref,preloader,opts){return function(){if(!ngUpgrade.$injector)throw new Error("\n        RouterUpgradeInitializer can be used only after UpgradeModule.bootstrap has been called.\n        Remove RouterUpgradeInitializer and call setUpLocationSync after UpgradeModule.bootstrap.\n      ");var router=ngUpgrade.injector.get(_angular_router.Router),ref=ngUpgrade.injector.get(_angular_core.ApplicationRef);router.resetRootComponentType(ref.componentTypes[0]),preloader.setUpPreloading(),opts.initialNavigation===!1?router.setUpLocationChangeListener():router.initialNavigation(),setUpLocationSync(ngUpgrade)}}function setUpLocationSync(ngUpgrade){var router=ngUpgrade.injector.get(_angular_router.Router),url=document.createElement("a");ngUpgrade.$injector.get("$rootScope").$on("$locationChangeStart",function(_,next,__){url.href=next,router.navigateByUrl(url.pathname)})}var RouterUpgradeInitializer={provide:_angular_router.ROUTER_INITIALIZER,useFactory:initialRouterNavigation,deps:[_angular_upgrade_static.UpgradeModule,_angular_core.ApplicationRef,_angular_router.RouterPreloader,_angular_router.ROUTER_CONFIGURATION]};exports.RouterUpgradeInitializer=RouterUpgradeInitializer,exports.initialRouterNavigation=initialRouterNavigation,exports.setUpLocationSync=setUpLocationSync});