1 import { NgModule, ApplicationRef } 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 { FileSelectDirective } from 'ng2-file-upload/ng2-file-upload';
9 import { ProgressbarModule } from 'ng2-bootstrap/components/progressbar';
10 import { PaginationModule } from 'ng2-bootstrap/components/pagination';
11 import { BytesPipe } from 'angular-pipes/src/math/bytes.pipe';
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';
21 import { AccountComponent, AccountService } from './account';
22 import { LoginComponent } from './login';
28 VideoMiniatureComponent,
45 import { MenuComponent } from './menu.component';
46 import { AuthService, AuthHttp, RestExtractor, RestService, SearchComponent, SearchService } from './shared';
48 // Application wide providers
49 const APP_PROVIDERS = [
54 useFactory: (backend: XHRBackend, defaultOptions: RequestOptions, authService: AuthService) => {
55 return new AuthHttp(backend, defaultOptions, authService);
57 deps: [ XHRBackend, RequestOptions, AuthService ]
62 RestExtractor, RestService, VideoService, SearchService, FriendService, UserService, AccountService
65 * `AppModule` is the main entry point into Angular2's bootstraping process
68 bootstrap: [ AppComponent ],
80 VideoMiniatureComponent,
93 imports: [ // import Angular's modules
98 RouterModule.forRoot(routes),
102 providers: [ // expose our Services and Providers into Angular's dependency injection
107 export class AppModule {
108 constructor(public appRef: ApplicationRef, public appState: AppState) {}
110 if (!store || !store.state) return;
111 console.log('HMR store', store);
112 this.appState._state = store.state;
116 hmrOnDestroy(store) {
117 const cmpLocation = this.appRef.components.map(cmp => cmp.location.nativeElement);
119 const state = this.appState._state;
121 store.disposeOldHosts = createNewHosts(cmpLocation);
125 hmrAfterDestroy(store) {
126 // display new elements
127 store.disposeOldHosts();
128 delete store.disposeOldHosts;