import { APP_INITIALIZER , ModuleWithProviders , NgModule , Optional , SkipSelf } from '@angular/core' ; import { BrowserModule } from '@angular/platform-browser' ; import { BrowserAnimationsModule } from '@angular/platform-browser/animations' ; import { NoConflictStyleCompatibilityMode } from '@angular/material' ; import { AngularFireModule } from 'angularfire2' ; import { AngularFireAuthModule } from 'angularfire2/auth' ; import { environment } from '../../environments/environment' ; import { SharedModule , ViewTitleService } from '../shared' ; export function provideViewTitleHandler ( viewTitle ) { return ( ) => { viewTitle . title . subscribe ( title => { document . title = title ? `Angular Lab - ${ title }` : 'Angular Lab' ; } ) ; } ; } /**
 * Module with service singletons.
 * Check https://angular.io/docs/ts/latest/guide/ngmodule.html#!#core-module for details why.
 */ @ NgModule ( { imports : [ BrowserAnimationsModule , NoConflictStyleCompatibilityMode , BrowserModule , AngularFireModule . initializeApp ( environment . firebase ) , AngularFireAuthModule , SharedModule ] , exports : [ SharedModule ] } ) export class CoreModule { constructor ( @ Optional ( ) @ SkipSelf ( ) parentModule ) { if ( parentModule ) { throw new Error ( 'angular-lab#CoreModule has already been loaded. Import it in the AppModule only.' ) ; } } static forRoot ( ) { return { ngModule : CoreModule , providers : [ { provide : APP_INITIALIZER , useFactory : provideViewTitleHandler , deps : [ ViewTitleService ] , multi : true } , ViewTitleService ] } ; } }