为什么日期管道无法在Angular 2中与ng2-bootstrap一起正常工作 [英] Why date pipe doesn't work properly with ng2-bootstrap in Angular 2

查看:96
本文介绍了为什么日期管道无法在Angular 2中与ng2-bootstrap一起正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以下一种格式显示日期:dd/MM/yyyy,但仅以MM/dd/yyyy显示.

I want to show date in next format: dd/MM/yyyy, but it only shows in MM/dd/yyyy.

这是我的startdateComponent:

import {Component, EventEmitter, Output, Input} from '@angular/core';
import {DATEPICKER_DIRECTIVES} from 'ng2-bootstrap/components/datepicker';

@Component({
templateUrl:'./app/home/item_component/start_date_component/start_date_component.html',
directives: [DATEPICKER_DIRECTIVES]
})
export class StartDateComponent () {
chosenDate : Date =  new Date();

getDate() {
    return this.chosenDate;
 }  
}

模板是:

 <div class="col-sm-1 col-sm-offset-1 datePicked ">
   <span>
     <h4>{{getDate() | date: 'dd/MM/yyyy'}}</h4>
   </span>
 </div>

这是怎么了?

推荐答案

我目前正在使用新的ng2-bootstrap datepicker,并将公开使用mo​​ment.js支持的日期格式,因此您可以使用以下任何格式:

I am currently working on new ng2-bootstrap datepicker and will expose moment.js powered date format, so you can use any format from: http://momentjs.com/docs/#/displaying/

如果您想尽快获得它并获取更新,请加入 https://www.hamsterpad.com/chat/ng2

PS if you want to get it asap and get updates, join https://www.hamsterpad.com/chat/ng2

这篇关于为什么日期管道无法在Angular 2中与ng2-bootstrap一起正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆