Search
 
SCRIPT & CODE EXAMPLE
 

HTML

return observable from function angular

1. Better practise is to use Observable:

import { catchError } from 'rxjs/operators';
import { throwError } from 'rxjs';

bbb() {
 return this.http.get(this.url)
   .pipe(
     catchError(err => {
       console.log('err', err);
       return throwError('Something bad happened; please try again later.');
     });
}

2. And, then simply just subscribe to bbb:

import { Subscription } from 'rxjs';

testSubscription: Subscription;

ngAfterContentInit() {
    this.testSubscription = this.bbb()
      .subscribe(son => {
        console.log('son', son); // here you get the result
      });
}

3. Don't forget to unsubscribe:

ngOnDestroy() {
  this.testSubscription.unsubscribe();
}
Comment

display observable in html angular

 
<!--.html file-  use '|async' pipe -->
<ul class=""  scope="row" *ngFor="let aboutus of this.pageData |async " >             
		<li>{{aboutus.key}} {{aboutus.data.details}} </li>                               
 </ul>
Comment

what is observable in angular

Observable in Angular is a feature that provides support 
for delivering messages between different parts of your single-page application.
This feature is frequently used in Angular because it is responsible 
for handling multiple values, asynchronous programming in Javascript, 
  and also event handling processes.
Comment

PREVIOUS NEXT
Code Example
Html :: srcset 
Html :: routerlink with params angular 
Html :: how to use body tag html 
Html :: editor html gratis online 
Html :: embedmd 
Html :: Przezroczysty div 
Html :: How to install Ubuntu 17.04 in VMWare Workstation 
Html :: <span class="notification-count"0</span 
Html :: servicenow jelly debug 
Html :: split input for otp 
Html :: horizontal news ticker 
Html :: how to 
Html :: js date for site 
Html :: convert html table to csv powershell 
Html :: Procent in html 
Html :: filetype: env"DB_PASSWORDS" 
Html :: Front-End WebHooks 
Html :: radio select gender 
Html :: brackeys C# 
Html :: etiqueta blockquote en html5 
Html :: hoe to make a html page attractive 
Html :: add img to botton 
Html :: get all classes in a html file 
Html :: falling star animation code 
Html :: how to make password in html correct or incorrect 
Html :: htlm param 
Html :: haw to fmake a link open in a new tag in html 
Html :: make element be positioned behind its parent, but in front of its grandparent 
Html :: how to give value to model from radio button html asp with enums if checked 
Html :: how to change db cred in wordpress 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =