Angular 6 CLI Workspaces. How to create library that exports services

前端 未结 6 1481
后悔当初
后悔当初 2021-01-01 18:20

Background:

  • Angular CLI 6 introduced the concept of workspaces.
  • A workspace can contain multiple projects.
  • The workspace and projects\' con
6条回答
  •  走了就别回头了
    2021-01-01 19:19

    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]
            };
          }
    }
    

提交回复
热议问题