ノードからサービスのonInitにオブジェクトの配列を取得し、コンポーネントに割り当てようとしています。私はサービス中のデータを見ることができますが、コンポーネント内の変数に代入しようとすると、以下のエラーが発生します。私は自分のコードも含めました。私が必要とするのは、サービスからその配列を取り出し、それをコンポーネント内のファイナリストに割り当てることだけです。プロパティ 'includes'が 'Subscription'タイプにはありません-angular2
ERROR in
C:/Users/girija/Documents/animapp/src/app/components/list.component.ts (28,5): Type 'Subscription' is not assignable to type 'any[]'.
Property 'includes' is missing in type 'Subscription'.
私のコードは以下の通りです: app.service.ts:
public finallist=[]
getList(){
return this.http.get('/api/list').subscribe(data=>{
this.finallist=JSON.parse(data['_body']);
return this.finallist;
})
}
app.component.ts:
totallist=[];
ngOnInit() {
this.totallist=this.someService.getList();
}
:
このような何かを試してみてください| – Gayathri