Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 注册服务时出现错误_Angular_Service_Dependency Injection - Fatal编程技术网

Angular 注册服务时出现错误

Angular 注册服务时出现错误,angular,service,dependency-injection,Angular,Service,Dependency Injection,请注意,在你否决我的答案之前,我已经在这个主题上搜索了多种解决方案,包括,但没有获得太多的成功 这是我的问题 我有一个依赖于RestapiService的有效组件。 所以我的构造函数看起来像: constructor(private store: Store<fromPlotData.PlotDataState>, private rest: RestapiService) { this.parseData(); store.select('plotDat

请注意,在你否决我的答案之前,我已经在这个主题上搜索了多种解决方案,包括,但没有获得太多的成功

这是我的问题

我有一个依赖于
RestapiService
的有效组件。 所以我的构造函数看起来像:

  constructor(private store: Store<fromPlotData.PlotDataState>, private rest: RestapiService) {
      this.parseData();
      store.select('plotData').subscribe(v => this.subscribeOnStore(v));
   }
我的服务如下所示:

@NgModule({
  declarations: [
    AppComponent,
    SpinnerComponent,
    FullComponent,
    NavigationComponent,
    BreadcrumbComponent,
    SidebarComponent,
    SetupviewComponent
  ],
  imports: [
    CommonModule,
    BrowserModule,
    BrowserAnimationsModule,
    FormsModule,
    HttpClientModule,
    NgbModule.forRoot(),
    RouterModule.forRoot(Approutes, { useHash: false }),
    PerfectScrollbarModule,
    StoreModule.forRoot(reducers),
    StoreDevtoolsModule.instrument({
      name: 'NgRx Book Store DevTools'
    }),
    TabsComponentsModule
  ],
  providers: [
    RestapiService, <--- This should obviously work
      {
      provide: PERFECT_SCROLLBAR_CONFIG,
      useValue: DEFAULT_PERFECT_SCROLLBAR_CONFIG
    }, {
    provide: LocationStrategy,
    useClass: HashLocationStrategy
  },
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';

const httpOptions = {
  header: new HttpHeaders({'Content-Type' : 'application/json'})
};
const API_URL = 'http://localhost:8000';


@Injectable()
export class RestapiService {

  constructor(
    private http: HttpClient
  ) { }


  getAxesParameter(id: number) {
    return this.http.get(API_URL + '/get_axes_parameter/' + id);
  }
   ................ Here goes 50 more API calls ...................

} // end of class
然而,我不断地得到一个静态注入错误

我尝试过删除
node\u模块
,从头开始安装所有模块,并多次运行,但没有成功

欢迎提出任何建议

我真傻

我找到了一个解决方案,它只是我的组件中服务的一个错误的相对路径

你可以结束这个问题