1

Hi i have this error from angular Can't resolve all parameters for RoomService: (?). i have this two files, on is the service.

room.service.ts

import { Injectable } from '@angular/core';
import { ResourceService } from './resource.service';
import { Http } from '@angular/http';
import { CONFIG as APP_CONSTANTS } from '../config/config';

@Injectable()
export class RoomService extends ResourceService {

  constructor(http) {
    super(http);
  }

}

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

// Angular Material
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MaterialComponents } from '../ngcomponents/material.component';

import { AppRoutingModule } from './app-routing.module';

// Components
import { AppComponent } from './app.component';
import { RoomlistComponent } from './components/roomlist/roomlist.component';

// services
import { HttpModule } from '@angular/http';
import { RoomService } from './services/room.service';

@NgModule({
  declarations: [
    AppComponent,
    RoomlistComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    HttpModule,
    BrowserAnimationsModule,
    MaterialComponents
  ],
  providers: [RoomService],
  bootstrap: [AppComponent]
})
export class AppModule { }

and i don´t have any idea what can the problem, any idea, just in case as you can see the RoomService is extending from another file resourceService i don´t know if that is the problem but i don´t think so.

3 Answers 3

2

constructor should have http parameter as of Http type. By which Dependency Resolver will get to know, he should create a token of Http injector.

constructor(http: Http) {
   super(http);
}
Sign up to request clarification or add additional context in comments.

Comments

0

Angular can't figure out what to pass because http doesn't have a type annotation

constructor(http) {

If you change it to

constructor(http:Http) {

and add HttpModule to imports: [...] of the AppModule, it should work. You also need to add a TypeScript import for Http.

See also

Comments

0

in your roomService, you DI should be

 constructor(http: Http) {
    super(http);
  }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.