I have two components details and details-view.
In the details I have to pass obserwable by @Input() into second component.
Details Component
res$: (id: number, type: string) => Observable<DetailsResponse[]>;
constructor(private service: Service) {
this.res$ = service.getData;
}
Service
getData(id: number, type: string): Observable<DetailsResponse[]>{
const params = new HttpParams().append('typename', type);
return this.http.get<any>('api/id', {params: params});
}
Detalis-View HTML
<dwtalis-view [resources$]="res$"></dwtalis-view>
Detalis-Viev TS Component
@Input()
resouces$: Observable<DetailsResponse[]>
My question is how to subscribe and get the data from resources$ observable in the detalis view component. Subscribing this object retunrs error "resources$ is not a finction can not subscribe"
this.res$ = service.getDatais just passing the function definition. If you actually want an observable, you need to execute the functionthis.res$ = service.getData(). Alternatively, if you do mean to pass the function definition then your typing forresource$is wrong, and it should be(id: number, type: string) => Observable<DetailsResponse[]>to matchres$from the parent component