Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 1 | import {BrowserModule} from '@angular/platform-browser'; |
| 2 | import {NgModule, APP_INITIALIZER} from '@angular/core'; |
| 3 | import {FormsModule} from '@angular/forms'; |
| 4 | import {forwardRef} from '@angular/core'; |
| 5 | import {AppComponent} from './app.component'; |
| 6 | import {UpgradeAdapter} from '@angular/upgrade'; |
| 7 | import {UpgradeModule} from '@angular/upgrade/static'; |
| 8 | import {PropertiesAssignmentModule} from './pages/properties-assignment/properties-assignment.module'; |
| 9 | import { |
| 10 | DataTypesServiceProvider, SharingServiceProvider, CookieServiceProvider, |
Michael Lando | b3d4898 | 2017-06-11 14:22:02 +0300 | [diff] [blame] | 11 | StateParamsServiceFactory, CacheServiceProvider, EventListenerServiceProvider |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 12 | } from "./utils/ng1-upgraded-provider"; |
| 13 | import {ConfigService} from "./services/config.service"; |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 14 | import {HttpModule} from '@angular/http'; |
| 15 | import {AuthenticationService} from './services/authentication.service'; |
| 16 | import {Cookie2Service} from "./services/cookie.service"; |
| 17 | import {ComponentServiceNg2} from "./services/component-services/component.service"; |
| 18 | import {ServiceServiceNg2} from "./services/component-services/service.service"; |
| 19 | import {ComponentInstanceServiceNg2} from "./services/component-instance-services/component-instance.service"; |
Tal Gitelman | ed7e1c3 | 2017-06-29 19:30:00 +0300 | [diff] [blame^] | 20 | import { InterceptorService } from 'ng2-interceptors'; |
| 21 | import { XHRBackend, RequestOptions } from '@angular/http'; |
| 22 | import {HttpInterceptor} from "./services/http.interceptor.service"; |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 23 | |
| 24 | export const upgradeAdapter = new UpgradeAdapter(forwardRef(() => AppModule)); |
| 25 | |
| 26 | export function configServiceFactory(config:ConfigService) { |
| 27 | return () => config.loadValidationConfiguration(); |
| 28 | } |
| 29 | |
Tal Gitelman | ed7e1c3 | 2017-06-29 19:30:00 +0300 | [diff] [blame^] | 30 | export function interceptorFactory(xhrBackend: XHRBackend, requestOptions: RequestOptions){ |
| 31 | let service = new InterceptorService(xhrBackend, requestOptions); |
| 32 | service.addInterceptor(new HttpInterceptor()); |
| 33 | return service; |
| 34 | } |
| 35 | |
| 36 | |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 37 | // export function httpServiceFactory(backend: XHRBackend, options: RequestOptions) { |
| 38 | // return new HttpService(backend, options); |
| 39 | // } |
| 40 | |
| 41 | @NgModule({ |
| 42 | declarations: [ |
| 43 | AppComponent |
| 44 | ], |
| 45 | imports: [ |
| 46 | BrowserModule, |
| 47 | UpgradeModule, |
| 48 | FormsModule, |
| 49 | HttpModule, |
| 50 | PropertiesAssignmentModule |
| 51 | ], |
| 52 | exports: [], |
| 53 | entryComponents: [], |
| 54 | providers: [ |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 55 | DataTypesServiceProvider, |
| 56 | SharingServiceProvider, |
| 57 | CookieServiceProvider, |
| 58 | StateParamsServiceFactory, |
Michael Lando | b3d4898 | 2017-06-11 14:22:02 +0300 | [diff] [blame] | 59 | CacheServiceProvider, |
| 60 | EventListenerServiceProvider, |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 61 | AuthenticationService, |
| 62 | Cookie2Service, |
| 63 | ConfigService, |
| 64 | ComponentServiceNg2, |
| 65 | ServiceServiceNg2, |
| 66 | ComponentInstanceServiceNg2, |
| 67 | { |
| 68 | provide: APP_INITIALIZER, |
| 69 | useFactory: configServiceFactory, |
| 70 | deps: [ConfigService], |
| 71 | multi: true |
Tal Gitelman | ed7e1c3 | 2017-06-29 19:30:00 +0300 | [diff] [blame^] | 72 | }, |
| 73 | { |
| 74 | provide: InterceptorService, |
| 75 | useFactory: interceptorFactory, |
| 76 | deps: [XHRBackend, RequestOptions] |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 77 | } |
| 78 | ], |
| 79 | bootstrap: [AppComponent] |
| 80 | }) |
| 81 | |
| 82 | |
| 83 | export class AppModule { |
| 84 | // ngDoBootstrap() {} |
| 85 | constructor(public upgrade:UpgradeModule) { |
| 86 | |
| 87 | |
| 88 | } |
| 89 | } |