2 个回答

你这种写法我没写过。不过你的ServicesModule 是不是应该出现在import里(在调用的模块)

import { NgModule, ModuleWithProviders } from "@angular/core";
import { CommonModule } from "@angular/common";
import { QuoteService } from "./quote.service";

export { QuoteService };

@NgModule()
export class ServicesModule {
  static forRoot(): ModuleWithProviders {
    return {
      ngModule: ServicesModule,
      providers: [QuoteService]
    };
  }
}
是forRoot不是forchild并且需要实时关注自己创建模块的位置和引用该模块的位置。