router-upgrade.umd.js 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /**
  2. * @license Angular v6.0.9
  3. * (c) 2010-2018 Google, Inc. https://angular.io/
  4. * License: MIT
  5. */
  6. (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/router'), require('@angular/upgrade/static')) :
  8. typeof define === 'function' && define.amd ? define('@angular/router/upgrade', ['exports', '@angular/core', '@angular/router', '@angular/upgrade/static'], factory) :
  9. (factory((global.ng = global.ng || {}, global.ng.router = global.ng.router || {}, global.ng.router.upgrade = {}),global.ng.core,global.ng.router,global.ng.upgrade.static));
  10. }(this, (function (exports,core,router,_static) { 'use strict';
  11. /**
  12. * @license
  13. * Copyright Google Inc. All Rights Reserved.
  14. *
  15. * Use of this source code is governed by an MIT-style license that can be
  16. * found in the LICENSE file at https://angular.io/license
  17. */
  18. /**
  19. * @description
  20. *
  21. * Creates an initializer that in addition to setting up the Angular
  22. * router sets up the ngRoute integration.
  23. *
  24. * ```
  25. * @NgModule({
  26. * imports: [
  27. * RouterModule.forRoot(SOME_ROUTES),
  28. * UpgradeModule
  29. * ],
  30. * providers: [
  31. * RouterUpgradeInitializer
  32. * ]
  33. * })
  34. * export class AppModule {
  35. * ngDoBootstrap() {}
  36. * }
  37. * ```
  38. *
  39. * @experimental
  40. */
  41. var RouterUpgradeInitializer = {
  42. provide: core.APP_BOOTSTRAP_LISTENER,
  43. multi: true,
  44. useFactory: locationSyncBootstrapListener,
  45. deps: [_static.UpgradeModule]
  46. };
  47. /**
  48. * @internal
  49. */
  50. function locationSyncBootstrapListener(ngUpgrade) {
  51. return function () { setUpLocationSync(ngUpgrade); };
  52. }
  53. /**
  54. * @description
  55. *
  56. * Sets up a location synchronization.
  57. *
  58. * History.pushState does not fire onPopState, so the Angular location
  59. * doesn't detect it. The workaround is to attach a location change listener
  60. *
  61. * @experimental
  62. */
  63. function setUpLocationSync(ngUpgrade) {
  64. if (!ngUpgrade.$injector) {
  65. 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 ");
  66. }
  67. var router$$1 = ngUpgrade.injector.get(router.Router);
  68. var url = document.createElement('a');
  69. ngUpgrade.$injector.get('$rootScope')
  70. .$on('$locationChangeStart', function (_, next, __) {
  71. url.href = next;
  72. router$$1.navigateByUrl(url.pathname + url.search + url.hash);
  73. });
  74. }
  75. /**
  76. * @license
  77. * Copyright Google Inc. All Rights Reserved.
  78. *
  79. * Use of this source code is governed by an MIT-style license that can be
  80. * found in the LICENSE file at https://angular.io/license
  81. */
  82. // This file only reexports content of the `src` folder. Keep it that way.
  83. /**
  84. * @license
  85. * Copyright Google Inc. All Rights Reserved.
  86. *
  87. * Use of this source code is governed by an MIT-style license that can be
  88. * found in the LICENSE file at https://angular.io/license
  89. */
  90. /**
  91. * Generated bundle index. Do not edit.
  92. */
  93. exports.RouterUpgradeInitializer = RouterUpgradeInitializer;
  94. exports.locationSyncBootstrapListener = locationSyncBootstrapListener;
  95. exports.setUpLocationSync = setUpLocationSync;
  96. Object.defineProperty(exports, '__esModule', { value: true });
  97. })));
  98. //# sourceMappingURL=router-upgrade.umd.js.map