Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

typescript function return type observable

//in the service file
getResults():Observable<any[]>{
        return this.httpClient.get<any>('/URL');
      }

//in the ts file
$observableResults = this.thatService.service.get()

//in the template

<div *ngFor='thing of ($observableResults | async)'>
  {{thing.something}}
</div>
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #typescript #function #return #type #observable
ADD COMMENT
Topic
Name
5+3 =