to return the mock data from Observable in angular service
Error Message: Generic type 'Observer<T> requires 1 type argument(s)
getDropdownData(request: string): Observable<DropdownData[]>{
const params = new HttpParams().append('request', request);
return this.http.get<DropdownData[]>(this.rootURL +'Home/DropdownData', { params });
let data: DropdownData[] = [
{
'label': 'Circle',
'Id': '10'
},
{
'label': 'Rectangle',
'Id': '20'
},
{
'label': 'Triangle',
'Id': '30'
},
{
'label': 'Pentagone',
'Id': '40'
}
];
return new Observable((observer: Observer<DropdownData[]>) => {
observer.next(data);
observer.complete();
});
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.