I'm in the process of migrating my app to the latest RC version and I've encountered some errors that I'm unable to resolve. Despite conducting an extensive search before seeking help here, I haven't been able to find a solution.
Upon clicking a button, the following should load:
Below is the component code:
import { Component, OnInit } from '@angular/core';
import { HTTPService } from '../shared/api.service';
import { Server } from './server.model';
import { SharedService } from '../shared/moveData.service';
@Component({
templateUrl: './mainserverpage.template.html',
})
export class MainServerPage implements OnInit {
constructor(private _httpService: HTTPService,
private _moveData: SharedService) { }
errorMessage: string;
public servers: Server[];
isLoading = true;
tillLoading;
selectedServer: Server;
currentServer;
isServerOnline=false;
ngOnInit() {
this.getServers('qa');
}
reloadServers(env) {
this.servers = null;
this.getServers(env);
}
getServers(env?) {
this._httpService.getServers(env)
.subscribe(
value => {
this.servers = value;
this.isLoading = false;
},
error => this.errorMessage = <any>error);
}
}
The module code is quite straightforward:
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { HttpModule } from '@angular/http';
import { SharedModule } from '../shared/shared.module';
import { MainServerPage } from './mainserverpage.component';
import { Server } from './server.model';
import { HTTPService } from '../shared/api.service';
@NgModule({
imports: [
CommonModule,
SharedModule,
HttpModule,
],
declarations: [
MainServerPage
],
exports: [
MainServerPage
],
providers: [
HTTPService
]
})
export class MainserverpageModule {
}
The routing setup:
import { RouterModule } from '@angular/router';
import { MainServerPage } from './mainserverpage.component';
export const mainRouting = RouterModule.forChild([
{ path: 'mainserverpage', component: MainServerPage }
]);
Lastly, the app.module that I'm utilizing. Omitting the template for brevity:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { SharedModule } from '../app/shared/shared.module';
import { MainserverpageModule } from '../app/servers/mainserverpage.module';
import { HomeComponent } from './home.component';
import { NavBarComponent } from './navbar.component';
import { NotFoundComponent } from '../app/shared/notfound.component';
import { MainServerPage } from '../app/servers/mainserverpage.component';
import { routing } from './app.routing';
import { mainRouting } from '../app/servers/mainserverpage.routing';
@NgModule({
declarations: [
AppComponent,
NavBarComponent,
HomeComponent,
NotFoundComponent,
MainServerPage
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
SharedModule,
routing,
mainRouting
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
The error I'm facing when trying to load this is as follows:
zone.js:420 Unhandled Promise rejection: No provider for HTTPService! ; Zone: angular ; Task: Promise.then ; Value: NoProviderError {__zone_symbol__error: Error: DI Error at NoProviderError.ZoneAwareError (http://localhost:4200/vendor.bundle.js:87143:…, _nativeError: ZoneAwareError, keys: Array[1], injectors: Array[1], __zone_symbol__message: "No provider for HTTPService!"…}__zone_symbol__error: Error: DI Error at NoProviderError.ZoneAwareError
While the solution might be simple for someone else, I'm unable to pinpoint the issue at my end. Thank you for your assistance.