i create a service and i want to share the data inside this service so i found in some tutorial that i have to bootstrap the service in the appmodule of my application to make sure that is only one instance of this service :
@NgModule({
declarations: [
AppComponent,
ProfileComponent,
TestComponent,
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
SlimLoadingBarModule.forRoot(),
FormWizardModule
],
exports: [BrowserModule, SlimLoadingBarModule],
providers: [UserResolverService,SessionService, appRoutingProviders ],
bootstrap: [AppComponent,[SessionService]]
})
export class AppModule { }
i make the SessionService in the boostrap but i have an error in the browser console :
zone.js:522 Unhandled Promise rejection: Component SessionService is not part of any NgModule or the module has not been imported into your module. ; Zone: ; Task: Promise.then ; Value: ZoneAwareError {__zone_symbol__error: Error: Component SessionService is not part of any NgModule or the module has not been imported into……} Error: Component SessionService is not part of any NgModule or the module has not been imported into your module.
this is my main.ts:
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { environment } from './environments/environment';
import { AppModule } from './app/app.module';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule);