12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /**
  2. * @license Angular v6.0.9
  3. * (c) 2010-2018 Google, Inc. https://angular.io/
  4. * License: MIT
  5. */
  6. import { APP_BOOTSTRAP_LISTENER } from '@angular/core';
  7. import { Router } from '@angular/router';
  8. import { UpgradeModule } from '@angular/upgrade/static';
  9. /**
  10. * @fileoverview added by tsickle
  11. * @suppress {checkTypes} checked by tsc
  12. */
  13. /**
  14. * \@description
  15. *
  16. * Creates an initializer that in addition to setting up the Angular
  17. * router sets up the ngRoute integration.
  18. *
  19. * ```
  20. * \@NgModule({
  21. * imports: [
  22. * RouterModule.forRoot(SOME_ROUTES),
  23. * UpgradeModule
  24. * ],
  25. * providers: [
  26. * RouterUpgradeInitializer
  27. * ]
  28. * })
  29. * export class AppModule {
  30. * ngDoBootstrap() {}
  31. * }
  32. * ```
  33. *
  34. * \@experimental
  35. */
  36. const /** @type {?} */ RouterUpgradeInitializer = {
  37. provide: APP_BOOTSTRAP_LISTENER,
  38. multi: true,
  39. useFactory: /** @type {?} */ (locationSyncBootstrapListener),
  40. deps: [UpgradeModule]
  41. };
  42. /**
  43. * \@internal
  44. * @param {?} ngUpgrade
  45. * @return {?}
  46. */
  47. function locationSyncBootstrapListener(ngUpgrade) {
  48. return () => { setUpLocationSync(ngUpgrade); };
  49. }
  50. /**
  51. * \@description
  52. *
  53. * Sets up a location synchronization.
  54. *
  55. * History.pushState does not fire onPopState, so the Angular location
  56. * doesn't detect it. The workaround is to attach a location change listener
  57. *
  58. * \@experimental
  59. * @param {?} ngUpgrade
  60. * @return {?}
  61. */
  62. function setUpLocationSync(ngUpgrade) {
  63. if (!ngUpgrade.$injector) {
  64. throw new Error(`
  65. RouterUpgradeInitializer can be used only after UpgradeModule.bootstrap has been called.
  66. Remove RouterUpgradeInitializer and call setUpLocationSync after UpgradeModule.bootstrap.
  67. `);
  68. }
  69. const /** @type {?} */ router = ngUpgrade.injector.get(Router);
  70. const /** @type {?} */ url = document.createElement('a');
  71. ngUpgrade.$injector.get('$rootScope')
  72. .$on('$locationChangeStart', (_, next, __) => {
  73. url.href = next;
  74. router.navigateByUrl(url.pathname + url.search + url.hash);
  75. });
  76. }
  77. /**
  78. * @fileoverview added by tsickle
  79. * @suppress {checkTypes} checked by tsc
  80. */
  81. // This file only reexports content of the `src` folder. Keep it that way.
  82. /**
  83. * @fileoverview added by tsickle
  84. * @suppress {checkTypes} checked by tsc
  85. */
  86. /**
  87. * Generated bundle index. Do not edit.
  88. */
  89. export { RouterUpgradeInitializer, locationSyncBootstrapListener, setUpLocationSync };
  90. //# sourceMappingURL=upgrade.js.map