Service instance is not available for child component in angular2

后端 未结 2 1773
栀梦
栀梦 2020-12-11 20:14

I have created some services which should be shared within whole application but for some reason child components are throwing error Error: DI Exception at NoProviderE

2条回答
  •  情歌与酒
    2020-12-11 20:44

    I think you do something the right way to specify your providers when bootstrapping your application.

    You probably don't import correctly your service in the boot module. You could check that categoryService isn't undefined here:

    import { categoryService } from './something';
    
    console.log(categoryService); // <-----
    
    bootstrap(AppComponent, [
      JwtHelper,
      HTTP_PROVIDERS, authervice, ROUTER_PROVIDERS, 
      categoryService,
      Configuration
    ]);
    

提交回复
热议问题