UNPKG

1.18 kBPlain TextView Raw
1import 'angular2-universal-polyfills/browser';
2import { enableProdMode } from '@angular/core';
3import { platformUniversalDynamic } from 'angular2-universal';
4import { AppModule } from './app/app.module';
5import 'bootstrap';
6const rootElemTagName = 'app'; // Update this if you change your root component selector
7
8// Enable either Hot Module Reloading or production mode
9if (module['hot']) {
10 module['hot'].accept();
11 module['hot'].dispose(() => {
12 // Before restarting the app, we create a new root element and dispose the old one
13 const oldRootElem = document.querySelector(rootElemTagName);
14 const newRootElem = document.createElement(rootElemTagName);
15 oldRootElem.parentNode.insertBefore(newRootElem, oldRootElem);
16 platform.destroy();
17 });
18} else {
19 enableProdMode();
20}
21
22// Boot the application, either now or when the DOM content is loaded
23const platform = platformUniversalDynamic();
24const bootApplication = () => { platform.bootstrapModule(AppModule); };
25if (document.readyState === 'complete') {
26 bootApplication();
27} else {
28 document.addEventListener('DOMContentLoaded', bootApplication);
29}