Skip to content

Instantly share code, notes, and snippets.

@pratikthecook
Created May 24, 2017 04:37
Async Pipe Example
import {Component} from '@angular/core';
@Component({
selector: 'async-pipe',
template: `
<h2>Async Pipe Example</h2>
<p>wait... {{promise | async}}</p>
<button (click)="clickMe()">Click me to initiate promise</button>
`
})
export class AsyncPipe {
promise : Promise <string> = null;
clickMe() {
this.promise = new Promise<string>((resolve, reject) => {
setTimeout(function () {
resolve("resolved");
},2000);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment