Angular 6 CLI Workspaces. How to create library that exports services
You can add services you want to export from your library by adding some code into public_api.ts
.
First locate projects/nameOfLibProject/src/public_api.ts
inside your angular app then add
export * from './lib/locationOf/your.service';
This might do the trick for you:
import { NgModule, ModuleWithProviders } from '@angular/core';
import { FormsLibComponent } from './forms-lib.component';
import { FormsLibService } from './forms-lib.service';
@NgModule({
declarations: [FormsLibComponent],
exports: [FormsLibComponent],
})
export class FormsLibModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: FormsLibModule,
providers: [FormsLibService]
};
}
}