1

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.

5

I was using angular router version

"@angular/router": "3.0.0"

and tried updating it to

"@angular/router": "3.1.0"

worked like a charm. :)

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.