ranyeli
9/11/2017 - 2:27 PM

App module

Shows how to initialize a service, component and a service variable

import { BrowserModule } from '@angular/platform-browser';
import { NgModule, APP_INITIALIZER } from '@angular/core';
import { HttpModule } from '@angular/http';

import { AppComponent } from './app.component';
import { SupplierComponent } from './components/supplier/supplier.component';

import { ApiCallService } from './service/apicall.service';
import { Resource } from './resources/resource';

@NgModule({
  declarations: [
    AppComponent,
    SupplierComponent
  ],
  imports: [
    BrowserModule,
    HttpModule
  ],
  providers: [
    ApiCallService, 
    Resource,
  {provide: APP_INITIALIZER,
    useFactory: (rs: Resource) => () => rs.getResource(),
    deps: [Resource], multi: true

  }],
  bootstrap: [AppComponent]
})
export class AppModule { }