Posts

Showing posts from March, 2020

How to use Async Pipe in Angular 8 Application ?

Image
Introduction  In this article, we are going to learn how to use async pipe in angular application.    What is Async Pipe ?  Async Pipe is an impure pipe which automatically subscribes to an observable to emit the latest values.It not only subscribe to an observable but also it subscribe to promise and calls the then method .When the components gets destroyed it automatically unsubscribe it to reduce memory leaks.   Advantages of Async Pipe   1)Async Pipe makes rendering of data from observable and promise easier. 2)For promises it automatically calls then method and  3)For observables  it automatically calls subscribe and unsubscribe.   Prerequisites Basic knowledge of Angular Visual Studio Code must be installed Angular CLI must be installed Node JS must be installed Step 1 Lets create a new Angular project using the following NPM command: ng  new   asyncPipe   Step 2 Now, let's create a new component by using the f