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 { FileUploadModule } from 'ng2-file-upload/ng2-file-upload';
15 * Platform and Environment providers/directives/pipes
17 import { ENV_PROVIDERS } from './environment';
18 import { routes } from './app.routes';
19 // App is our top level component
20 import { AppComponent } from './app.component';
21 import { AppState } from './app.service';
31 RequestStatsComponent,
38 import { AccountComponent, AccountService } from './account';
39 import { LoginComponent } from './login';
40 import { MenuComponent } from './menu.component';
41 import { AuthService, AuthHttp, RestExtractor, RestService, SearchComponent, SearchService } from './shared';
47 VideoMiniatureComponent,
54 // Application wide providers
55 const APP_PROVIDERS = [
60 useFactory: (backend: XHRBackend, defaultOptions: RequestOptions, authService: AuthService) => {
61 return new AuthHttp(backend, defaultOptions, authService);
63 deps: [ XHRBackend, RequestOptions, AuthService ]
79 * `AppModule` is the main entry point into Angular2's bootstraping process
82 bootstrap: [ AppComponent ],
96 RequestStatsComponent,
103 VideoMiniatureComponent,
108 imports: [ // import Angular's modules
113 RouterModule.forRoot(routes),
120 providers: [ // expose our Services and Providers into Angular's dependency injection
125 export class AppModule {
126 constructor(public appRef: ApplicationRef, public appState: AppState) {}
128 if (!store || !store.state) return;
129 console.log('HMR store', store);
130 this.appState._state = store.state;
134 hmrOnDestroy(store) {
135 const cmpLocation = this.appRef.components.map(cmp => cmp.location.nativeElement);
137 const state = this.appState._state;
139 store.disposeOldHosts = createNewHosts(cmpLocation);
143 hmrAfterDestroy(store) {
144 // display new elements
145 store.disposeOldHosts();
146 delete store.disposeOldHosts;