mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-24 02:30:13 +00:00
Update to Angular 4 (but leave directory name as Angular2Spa until finished)
This commit is contained in:
@@ -1,29 +1,22 @@
|
||||
import 'angular2-universal-polyfills/browser';
|
||||
import 'reflect-metadata';
|
||||
import 'zone.js';
|
||||
import { enableProdMode } from '@angular/core';
|
||||
import { platformUniversalDynamic } from 'angular2-universal';
|
||||
import { AppModule } from './app/app.module';
|
||||
import 'bootstrap';
|
||||
const rootElemTagName = 'app'; // Update this if you change your root component selector
|
||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
import { AppModule } from './app/app.module.client';
|
||||
|
||||
// Enable either Hot Module Reloading or production mode
|
||||
if (module['hot']) {
|
||||
module['hot'].accept();
|
||||
module['hot'].dispose(() => {
|
||||
// Before restarting the app, we create a new root element and dispose the old one
|
||||
const oldRootElem = document.querySelector(rootElemTagName);
|
||||
const newRootElem = document.createElement(rootElemTagName);
|
||||
const oldRootElem = document.querySelector('app');
|
||||
const newRootElem = document.createElement('app');
|
||||
oldRootElem.parentNode.insertBefore(newRootElem, oldRootElem);
|
||||
platform.destroy();
|
||||
modulePromise.then(appModule => appModule.destroy());
|
||||
});
|
||||
} else {
|
||||
enableProdMode();
|
||||
}
|
||||
|
||||
// Boot the application, either now or when the DOM content is loaded
|
||||
const platform = platformUniversalDynamic();
|
||||
const bootApplication = () => { platform.bootstrapModule(AppModule); };
|
||||
if (document.readyState === 'complete') {
|
||||
bootApplication();
|
||||
} else {
|
||||
document.addEventListener('DOMContentLoaded', bootApplication);
|
||||
}
|
||||
// Note: @ng-tools/webpack looks for the following expression when performing production
|
||||
// builds. Don't change how this line looks, otherwise you may break tree-shaking.
|
||||
const modulePromise = platformBrowserDynamic().bootstrapModule(AppModule);
|
||||
|
||||
Reference in New Issue
Block a user