I've google a lot for the issue but haven't find any related article or stackoverflow question though there are many question with the same title but different in scenario. I have not been able to require dependencies on the constructor of a service which is why I am getting the this error.
Bootstrap at least one component before injecting Router. ; Zone: <root> ; Task: Promise.then ; Value: Error: Bootstrap at least one component before
Note : If I just clear the constructor dependencies defined in the CustomerService class then it works like a charm.
@Injectable()
export class CustomerService
constructor(private authService: AuthService, private siteService: SiteService) { }
AuthService and Site Service Class and It's dependencies are loaded with no problem. Just some sudo facade of AuthService and SiteService Class
@Injectable()
export class AuthService
constructor(private http: Http, private storageService: StorageService,
private siteService: SiteService, private router: Router) {}
@Injectable()
export class SiteService {
constructor(private http: Http, private storageService: StorageService) {}
And also App Module @ngModule decorator.
@NgModule({
declarations: [
AppComponent,
AuthComponent,
LoginComponent,
HeaderComponent,
SignupComponent,
CompanyComponent,
Step2Component
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
AngularAppRoutingModule
],
providers: [ AuthGuard, AuthService, StorageService, StepsNavigatorGuard, SiteService, CustomerService],
bootstrap: [AppComponent]
})
Note: The issue just remains with the CustomerService. If I try to remove it from the provider array in AppModule or clear it's constructor dependencies then the app runs fine.
Any help would be appreciated alot.
@NgModule()of your root component. – Günter Zöchbauer Oct 14 '16 at 11:04AuthServicetoAppComponent. – Günter Zöchbauer Oct 14 '16 at 11:07AppComponentaswell – Clean code Oct 14 '16 at 11:11