首页 > 其他 > 详细

[Angular 2] Rendering an Observable Date with the Async and Date Pipes

时间:2016-04-26 07:03:46      阅读:236      评论:0      收藏:0      [点我收藏+]

Instead of simply pushing numbers on a timer into the template, now we‘ll move on to pushing actual Dates. We‘ll still use the Async pipe, but we‘ll also add on the Date pipe with some formatting to display the Date just the way we want it.

 

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

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

class App {
    clock = Observable.interval(1000)
        .map( () => new Date());
}

bootstrap(App);

 

Monday, April 25, 2016, 10:16:50 PM

[Angular 2] Rendering an Observable Date with the Async and Date Pipes

原文:http://www.cnblogs.com/Answer1215/p/5433551.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!