2016-07-13 6 views
0

次の形式で日付を表示したい:dd/MM/yyyyですが、それはMM/dd/yyyyにのみ表示されます。ここでAngular 2のng2-bootstrapでdate pipeが正常に動作しない理由

は私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> 

ここで間違っていますか?

答えて

0

私は同じ質問をしました。ここで答え、from the sourceは次のとおりです。

* ## Usage 
* 
*  expression | date[:format] 
* 
* where `expression` is a date object or a number (milliseconds 
* since UTC epoch) or an ISO string 
* (https://www.w3.org/TR/NOTE-datetime) and `format` indicates which 
* date/time components to 
* include: 
... 
* In javascript, only the components specified will be respected 
* (not the ordering, 
* punctuations, ...) and details of the formatting will be dependent 
* on the locale. 

ので答えは、ある「formatは、あなたはそれが動作するように期待するように動作しませんので。」

+0

ありがとう!.. yeappp ... – Serhiy

0

あなたから任意の形式を使用することができますので、私は、現在、新しいNG2-ブートストラップ日付ピッカーに取り組んでいますし、日付形式をパワードmoment.jsを公開します:あなたはそれをできるだけ早く取得し、更新情報を取得するには、参加したい場合はhttp://momentjs.com/docs/#/displaying/

PS https://www.hamsterpad.com/chat/ng2

関連する問題