2016-07-13 3 views
0

다음 형식으로 날짜를 표시하려고합니다 : dd/MM/yyyy, 그러나 이는 MM/dd/yyyy에만 표시됩니다. 여기각도 2의 ng2-bootstrap에서 날짜 파이프가 제대로 작동하지 않는 이유

은 내 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

나는 동일한 질문이 있었다. "format는 당신이 일을 예상대로 작동하지 않기 때문에."

* ## 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. 

그래서 대답은, 다음은 대답 from the source입니다

+0

감사합니다! ... yeappp ... – Serhiy