ngx-admin/src/main.browser.ts

57 lines
1.5 KiB
TypeScript
Raw Normal View History

2016-04-20 16:32:12 +03:00
/*
* Providers provided by Angular
*/
import { bootstrap } from '@angular/platform-browser-dynamic';
2016-04-20 16:32:12 +03:00
/*
2016-04-21 17:41:28 +03:00
* Platform and Environment
* our providers/directives/pipes
*/
import { PLATFORM_PROVIDERS } from './platform/browser';
import { ENV_PROVIDERS, decorateComponentRef } from './platform/environment';
2016-04-20 16:32:12 +03:00
/*
2016-04-21 17:41:28 +03:00
* App Component
* our top level component that holds all of our components
*/
import { App, APP_PROVIDERS } from './app';
2016-04-21 17:41:28 +03:00
2016-04-20 16:32:12 +03:00
/*
* Bootstrap our Angular app with a top level component `App` and inject
* our Services and Providers into Angular's dependency injection
*/
export function main(initialHmrState?: any): Promise<any> {
return bootstrap(App, [
// To add more vendor providers please look in the platform/ folder
...PLATFORM_PROVIDERS,
2016-04-20 16:32:12 +03:00
...ENV_PROVIDERS,
...APP_PROVIDERS,
2016-04-20 16:32:12 +03:00
])
.then(decorateComponentRef)
.catch(err => console.error(err));
2016-04-20 16:32:12 +03:00
}
/*
* Vendors
* For vendors for example jQuery, Lodash, angular2-jwt just import them anywhere in your app
* You can also import them in vendors to ensure that they are bundled in one file
* Also see custom-typings.d.ts as you also need to do `typings install x` where `x` is your module
*/
/*
* Hot Module Reload
* experimental version by @gdi2290
*/
if ('development' === ENV && HMR === true) {
// activate hot module reload
let ngHmr = require('angular2-hmr');
ngHmr.hotModuleReplacement(main, module);
} else {
// bootstrap when document is ready
2016-04-20 16:32:12 +03:00
document.addEventListener('DOMContentLoaded', () => main());
}