30 lines
676 B
TypeScript
30 lines
676 B
TypeScript
import { NgModule, Optional, SkipSelf } from '@angular/core';
|
|
import { CommonModule } from '@angular/common';
|
|
import { ContactService } from './contact.service';
|
|
import { ContactFormService } from './services/contact-form.service';
|
|
|
|
@NgModule({
|
|
declarations: [],
|
|
imports: [
|
|
CommonModule
|
|
]
|
|
})
|
|
export class ContactModule {
|
|
constructor(
|
|
@Optional()
|
|
@SkipSelf()
|
|
parentModule: ContactModule
|
|
) {
|
|
if (parentModule) {
|
|
throw new Error('ContactModule is already loaded. Import it in the AppModule only');
|
|
}
|
|
}
|
|
|
|
static forRoot() {
|
|
return {
|
|
ngModule: ContactModule,
|
|
providers: [ ContactService, ContactFormService ]
|
|
}
|
|
}
|
|
}
|