您的位置:首页 > Web前端 > AngularJS

[Angular 2] Rendering an Observable with the Async Pipe

2016-04-26 03:12 561 查看
Angular 2 templates use a special Async pipe to be able to render out Observables. This lesson covers the syntax used to create an Observable in Angular 2 and then to render it out in the template.

import {Component} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/observable/interval'

@Component({
selector: 'app',
template: `<h1>{{clock | async}}</h1>`
})

class App {
clock = Observable.interval(1000);
}

bootstrap(App);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: