Angular 未捕获错误:意外值';SearchserviceModule';由模块';AppModule';。请添加@Pipe/@Directive/@组件注释

Angular 未捕获错误:意外值';SearchserviceModule';由模块';AppModule';。请添加@Pipe/@Directive/@组件注释,angular,Angular,我在这一点上陷入了这个错误,希望你们中的一些专家能帮助我解决这个问题。在我添加搜索栏之前,我的网站运行良好(只是一个了解angular更多信息的小项目),我不知道哪里出了问题,因为我尝试搜索我的app.module以查找错误,但我看不到任何错误 干杯 未捕获错误:模块“AppModule”声明的意外值“SearchserviceModule”。请添加@Pipe/@Directive/@组件注释 **我的app.module.ts看起来像这样** 在这里输入代码 从“@angular/platfo

我在这一点上陷入了这个错误,希望你们中的一些专家能帮助我解决这个问题。在我添加搜索栏之前,我的网站运行良好(只是一个了解angular更多信息的小项目),我不知道哪里出了问题,因为我尝试搜索我的app.module以查找错误,但我看不到任何错误

干杯

未捕获错误:模块“AppModule”声明的意外值“SearchserviceModule”。请添加@Pipe/@Directive/@组件注释

**我的app.module.ts看起来像这样**
在这里输入代码
从“@angular/platform browser”导入{BrowserModule};
从“@angular/core”导入{NgModule};
从'@angular/forms'导入{FormsModule};
从'@angular/http'导入{HttpModule};
从'@angular/router'导入{RouterModule};
从“./app.component”导入{AppComponent};
从“./movielist/movielist.component”导入{MovielistComponent};
从“./searchservice/searchservice.module”导入{SearchserviceModule};
@NGD模块({
声明:[
应用组件,
电影组分,
搜索服务模块,
],
进口:[
浏览器模块,
FormsModule,
HttpModule,
RouterModule.forRoot([
{
路径:“movielist”,
组件:MovielistComponent
},
])
],
提供者:[],
引导:[AppComponent]
})
导出类AppModule{}
**我的app.component.ts看起来像这样**
从'@angular/core'导入{Component};
从'@angular/Http'导入{Http,Response};
从“rxjs/Observable”导入{Observable};
导入'rxjs/add/operator/map';
从“./searchservice/searchservice.module”导入{SearchserviceModule};
从'rxjs/Subject'导入{Subject};
@组成部分({
选择器:'应用程序根',
templateUrl:“./app.component.html”,
样式URL:['./app.component.css'],
提供者:[SearchserviceModule]
})
导出类AppComponent{
结果:对象;
searchTerm$=新主题();
构造函数(专用searchService:SearchserviceModule){
this.searchService.search(this.searchTerm$)
.订阅(结果=>{
this.results=results.results;
});
}
}
**我的searchservice.module.ts如下所示**
从“@angular/core”导入{Injectable};
从'@angular/Http'导入{Http};
从“rxjs/Observable”导入{Observable};
导入'rxjs/add/operator/map';
导入'rxjs/add/operator/debounceTime';
导入'rxjs/add/operator/distinctUntilChanged';
导入'rxjs/add/operator/switchMap';
@可注射()
导出类SearchserviceModule{
baseUrl:string='1〕https://api.cdnjs.com/libraries';
queryUrl:string='?search=';
构造函数(私有http:http){}
搜索(术语:可观察){
退货条款。退保时间(400)
.distinctUntilChanged()
.switchMap(term=>this.searchEntries(term));
}
搜索条目(术语){
返回此文件。http
.get(this.baseUrl+this.queryUrl+term)
.map(res=>res.json());
}
}

将SearchserviceModule添加到提供者而不是声明:

@NgModule({
declarations: [
 AppComponent,
 MovielistComponent

],
imports: [
 BrowserModule,
 FormsModule,
 HttpModule,
 RouterModule.forRoot([
   {
   path: 'movielist',
   component: MovielistComponent
   },
])
],
providers: [SearchserviceModule],
bootstrap: [AppComponent]
})
 export class AppModule { }

这个答案将解决您的问题,我建议您在“search.service.ts”文件中用“SearchService”重命名“SearchserviceModule”。像这样,您将遵循角度命名标准。是的,您是对的@Yanis git,SearchserviceModule令人困惑,不清楚它是模块还是服务
@NgModule({
declarations: [
 AppComponent,
 MovielistComponent

],
imports: [
 BrowserModule,
 FormsModule,
 HttpModule,
 RouterModule.forRoot([
   {
   path: 'movielist',
   component: MovielistComponent
   },
])
],
providers: [SearchserviceModule],
bootstrap: [AppComponent]
})
 export class AppModule { }