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 { DropdownModule } from 'ng2-bootstrap/components/dropdown';
10 import { ProgressbarModule } from 'ng2-bootstrap/components/progressbar';
11 import { PaginationModule } from 'ng2-bootstrap/components/pagination';
12 import { ModalModule } from 'ng2-bootstrap/components/modal';
13 import { FileUploadModule } from 'ng2-file-upload/ng2-file-upload';
16 * Platform and Environment providers/directives/pipes
18 import { ENV_PROVIDERS } from './environment';
19 import { routes } from './app.routes';
20 // App is our top level component
21 import { AppComponent } from './app.component';
22 import { AppState } from './app.service';
32 RequestStatsComponent,
39 import { AccountComponent, AccountService } from './account';
40 import { LoginComponent } from './login';
41 import { MenuComponent } from './menu.component';
42 import { AuthService, AuthHttp, RestExtractor, RestService, SearchComponent, SearchService } from './shared';
48 VideoMiniatureComponent,
55 // Application wide providers
56 const APP_PROVIDERS = [
61 useFactory: (backend: XHRBackend, defaultOptions: RequestOptions, authService: AuthService) => {
62 return new AuthHttp(backend, defaultOptions, authService);
64 deps: [ XHRBackend, RequestOptions, AuthService ]
80 * `AppModule` is the main entry point into Angular2's bootstraping process
83 bootstrap: [ AppComponent ],
97 RequestStatsComponent,
104 VideoMiniatureComponent,
109 imports: [ // import Angular's modules
114 RouterModule.forRoot(routes),
122 providers: [ // expose our Services and Providers into Angular's dependency injection
127 export class AppModule {
128 constructor(public appRef: ApplicationRef, public appState: AppState) {}
130 if (!store || !store.state) return;
131 console.log('HMR store', store);
132 this.appState._state = store.state;
136 hmrOnDestroy(store) {
137 const cmpLocation = this.appRef.components.map(cmp => cmp.location.nativeElement);
139 const state = this.appState._state;
141 store.disposeOldHosts = createNewHosts(cmpLocation);
145 hmrAfterDestroy(store) {
146 // display new elements
147 store.disposeOldHosts();
148 delete store.disposeOldHosts;