From 57d46442c69f33821c63f22106f3188b67d2d7e5 Mon Sep 17 00:00:00 2001 From: "Kevin C. Coram" Date: Thu, 5 Sep 2019 22:56:08 -0400 Subject: [PATCH] Refactor move ContactFormService into contact library --- apps/global-form/src/app/app.component.spec.ts | 12 ++++++++---- apps/global-form/src/app/app.component.ts | 7 +++++-- libs/contact/src/index.ts | 1 + libs/contact/src/lib/contact.module.ts | 3 ++- .../src/lib}/services/contact-form.service.spec.ts | 0 .../src/lib}/services/contact-form.service.ts | 0 6 files changed, 16 insertions(+), 7 deletions(-) rename {apps/global-form/src/app => libs/contact/src/lib}/services/contact-form.service.spec.ts (100%) rename {apps/global-form/src/app => libs/contact/src/lib}/services/contact-form.service.ts (100%) diff --git a/apps/global-form/src/app/app.component.spec.ts b/apps/global-form/src/app/app.component.spec.ts index 8f9f339..a59e4aa 100644 --- a/apps/global-form/src/app/app.component.spec.ts +++ b/apps/global-form/src/app/app.component.spec.ts @@ -6,7 +6,6 @@ import { NameComponent } from './name/name.component'; import { AddressListComponent } from './address-list/address-list.component'; import { AddressComponent } from './address/address.component'; import { ContactModule } from '@nested-forms/contact'; -import { ContactFormService } from './services/contact-form.service'; describe('AppComponent', () => { beforeEach(async(() => { @@ -14,10 +13,15 @@ describe('AppComponent', () => { imports: [ RouterTestingModule, ReactiveFormsModule, - ContactModule.forRoot() + ContactModule.forRoot(), ], - declarations: [AppComponent, NameComponent, AddressComponent, AddressListComponent], - providers: [ ContactFormService ], + declarations: [ + AppComponent, + NameComponent, + AddressComponent, + AddressListComponent, + ], + providers: [], }).compileComponents(); })); diff --git a/apps/global-form/src/app/app.component.ts b/apps/global-form/src/app/app.component.ts index e618955..927dff8 100644 --- a/apps/global-form/src/app/app.component.ts +++ b/apps/global-form/src/app/app.component.ts @@ -1,8 +1,11 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; import { FormGroup } from '@angular/forms'; -import { Contact, ContactService } from '@nested-forms/contact'; +import { + Contact, + ContactService, + ContactFormService, +} from '@nested-forms/contact'; import { Subscription } from 'rxjs'; -import { ContactFormService } from './services/contact-form.service'; @Component({ selector: 'nested-forms-root', diff --git a/libs/contact/src/index.ts b/libs/contact/src/index.ts index e623161..e9f159c 100644 --- a/libs/contact/src/index.ts +++ b/libs/contact/src/index.ts @@ -1,3 +1,4 @@ export * from './lib/contact-model'; export * from './lib/contact.service'; +export * from './lib/services/contact-form.service'; export * from './lib/contact.module'; \ No newline at end of file diff --git a/libs/contact/src/lib/contact.module.ts b/libs/contact/src/lib/contact.module.ts index bdb780d..15f0df2 100644 --- a/libs/contact/src/lib/contact.module.ts +++ b/libs/contact/src/lib/contact.module.ts @@ -1,6 +1,7 @@ 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: [], @@ -22,7 +23,7 @@ export class ContactModule { static forRoot() { return { ngModule: ContactModule, - providers: [ ContactService ] + providers: [ ContactService, ContactFormService ] } } } diff --git a/apps/global-form/src/app/services/contact-form.service.spec.ts b/libs/contact/src/lib/services/contact-form.service.spec.ts similarity index 100% rename from apps/global-form/src/app/services/contact-form.service.spec.ts rename to libs/contact/src/lib/services/contact-form.service.spec.ts diff --git a/apps/global-form/src/app/services/contact-form.service.ts b/libs/contact/src/lib/services/contact-form.service.ts similarity index 100% rename from apps/global-form/src/app/services/contact-form.service.ts rename to libs/contact/src/lib/services/contact-form.service.ts