[Angular 2] Rendering an Observable Date with the Async and Date Pipes
2023-09-14 09:00:54 时间
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 应用 [含懒加载]
- Angular和Vue.js 深度对比
- angular子组件传值到父组件_vue子组件传值给父组件
- 如何在Angular项目中使用MQTT
- angular 路由懒加载_angular路由
- 关于 Angular 应用的入口
- 关于 Angular Universal 应用执行时需要 Browser API 的问题
- 【Angular教程】-内容投影u002F@ContentChildu002F@ViewChild
- 关于 Angular 工程文件 angular.json 里的 inlineCritical 属性
- Angular 项目中 angular.json builder 字段的可选项介绍
- Angular 应用里 server.ts 文件的 APP_BASE_HREF token 的用法?
- 什么是 Angular library 的 secondary entry points?
- 关于 Angular 12 的 inlineCriticalCss 选项
- 基于豆瓣API+Angular开发的webApp
- 使用angular写一个helloworld