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';
10 import { DropdownModule } from 'ng2-bootstrap/components/dropdown';
11 import { ProgressbarModule } from 'ng2-bootstrap/components/progressbar';
12 import { PaginationModule } from 'ng2-bootstrap/components/pagination';
13 import { ModalModule } from 'ng2-bootstrap/components/modal';
15 import { FileUploadModule } from 'ng2-file-upload/ng2-file-upload';
17 import { MetaConfig, MetaModule } from 'ng2-meta';
20 * Platform and Environment providers/directives/pipes
22 import { ENV_PROVIDERS } from './environment';
23 import { routes } from './app.routes';
24 // App is our top level component
25 import { AppComponent } from './app.component';
26 import { AppState } from './app.service';
36 RequestStatsComponent,
43 import { AccountComponent, AccountService } from './account';
44 import { LoginComponent } from './login';
45 import { MenuComponent } from './menu.component';
46 import { AuthService, AuthHttp, RestExtractor, RestService, SearchComponent, SearchService } from './shared';
52 VideoMiniatureComponent,
59 const metaConfig: MetaConfig = {
60 //Append a title suffix such as a site name to all titles
68 // Application wide providers
69 const APP_PROVIDERS = [
74 useFactory: (backend: XHRBackend, defaultOptions: RequestOptions, authService: AuthService) => {
75 return new AuthHttp(backend, defaultOptions, authService);
77 deps: [ XHRBackend, RequestOptions, AuthService ]
93 * `AppModule` is the main entry point into Angular2's bootstraping process
96 bootstrap: [ AppComponent ],
110 RequestStatsComponent,
117 VideoMiniatureComponent,
122 imports: [ // import Angular's modules
127 RouterModule.forRoot(routes),
136 MetaModule.forRoot(metaConfig)
138 providers: [ // expose our Services and Providers into Angular's dependency injection
143 export class AppModule {
144 constructor(public appRef: ApplicationRef, public appState: AppState) {}
146 if (!store || !store.state) return;
147 console.log('HMR store', store);
148 this.appState._state = store.state;
152 hmrOnDestroy(store) {
153 const cmpLocation = this.appRef.components.map(cmp => cmp.location.nativeElement);
155 const state = this.appState._state;
157 store.disposeOldHosts = createNewHosts(cmpLocation);
161 hmrAfterDestroy(store) {
162 // display new elements
163 store.disposeOldHosts();
164 delete store.disposeOldHosts;