1 import { ApplicationRef, NgModule } from '@angular/core';
2 import { BrowserModule } from '@angular/platform-browser';
3 import { FormsModule, ReactiveFormsModule } from '@angular/forms';
4 import { HttpModule, RequestOptions, XHRBackend } from '@angular/http';
5 import { RouterModule } from '@angular/router';
6 import { removeNgStyles, createNewHosts } from '@angularclass/hmr';
8 import { BytesPipe } from 'angular-pipes/src/math/bytes.pipe';
9 import { ProgressbarModule } from 'ng2-bootstrap/components/progressbar';
10 import { PaginationModule } from 'ng2-bootstrap/components/pagination';
11 import { FileUploadModule } from 'ng2-file-upload/ng2-file-upload';
14 * Platform and Environment providers/directives/pipes
16 import { ENV_PROVIDERS } from './environment';
17 import { routes } from './app.routes';
18 // App is our top level component
19 import { AppComponent } from './app.component';
20 import { AppState } from './app.service';
30 RequestStatsComponent,
37 import { AccountComponent, AccountService } from './account';
38 import { LoginComponent } from './login';
39 import { MenuComponent } from './menu.component';
40 import { AuthService, AuthHttp, RestExtractor, RestService, SearchComponent, SearchService } from './shared';
46 VideoMiniatureComponent,
53 // Application wide providers
54 const APP_PROVIDERS = [
59 useFactory: (backend: XHRBackend, defaultOptions: RequestOptions, authService: AuthService) => {
60 return new AuthHttp(backend, defaultOptions, authService);
62 deps: [ XHRBackend, RequestOptions, AuthService ]
78 * `AppModule` is the main entry point into Angular2's bootstraping process
81 bootstrap: [ AppComponent ],
95 RequestStatsComponent,
102 VideoMiniatureComponent,
107 imports: [ // import Angular's modules
112 RouterModule.forRoot(routes),
118 providers: [ // expose our Services and Providers into Angular's dependency injection
123 export class AppModule {
124 constructor(public appRef: ApplicationRef, public appState: AppState) {}
126 if (!store || !store.state) return;
127 console.log('HMR store', store);
128 this.appState._state = store.state;
132 hmrOnDestroy(store) {
133 const cmpLocation = this.appRef.components.map(cmp => cmp.location.nativeElement);
135 const state = this.appState._state;
137 store.disposeOldHosts = createNewHosts(cmpLocation);
141 hmrAfterDestroy(store) {
142 // display new elements
143 store.disposeOldHosts();
144 delete store.disposeOldHosts;