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 { FileSelectDirective } 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';
34 import { AccountComponent, AccountService } from './account';
35 import { LoginComponent } from './login';
36 import { MenuComponent } from './menu.component';
37 import { AuthService, AuthHttp, RestExtractor, RestService, SearchComponent, SearchService } from './shared';
43 VideoMiniatureComponent,
50 // Application wide providers
51 const APP_PROVIDERS = [
56 useFactory: (backend: XHRBackend, defaultOptions: RequestOptions, authService: AuthService) => {
57 return new AuthHttp(backend, defaultOptions, authService);
59 deps: [ XHRBackend, RequestOptions, AuthService ]
74 * `AppModule` is the main entry point into Angular2's bootstraping process
77 bootstrap: [ AppComponent ],
97 VideoMiniatureComponent,
102 imports: [ // import Angular's modules
107 RouterModule.forRoot(routes),
112 providers: [ // expose our Services and Providers into Angular's dependency injection
117 export class AppModule {
118 constructor(public appRef: ApplicationRef, public appState: AppState) {}
120 if (!store || !store.state) return;
121 console.log('HMR store', store);
122 this.appState._state = store.state;
126 hmrOnDestroy(store) {
127 const cmpLocation = this.appRef.components.map(cmp => cmp.location.nativeElement);
129 const state = this.appState._state;
131 store.disposeOldHosts = createNewHosts(cmpLocation);
135 hmrAfterDestroy(store) {
136 // display new elements
137 store.disposeOldHosts();
138 delete store.disposeOldHosts;