2017-10-18 5 views
0

私は、Dateカラムを持つJSONオブジェクト用のインターフェースを持っています。表示されるのは、エポックからの秒数です。 日付の値を書式設定しようとしていますが、運があまりありません。フォーマットされた日付をprimengの​​p-columnにどのように追加しますか?

誰かが正しい方向に私を向けることができますか?

<p-dataTable [value]="observations" [rows]="20" [paginator]="true" [responsive]=true selectionMode="single" [(selection)]="selectedObservation" (onRowSelect)="onRowSelect($event)"> 
    <p-header>List of Observations</p-header> 
    <p-column field="id" header="ID" [sortable]="true" [style]="{'width': '100px'}"></p-column> 
    <p-column field="description" header="Description" [sortable]="true"></p-column> 
    <p-column field="citation.id" header="CitationID" [sortable]="true" [style]="{'width': '100px'}"></p-column> 
    <p-column field="citation.citationShortDescription" header="Citation Short Description" [sortable]="true"></p-column> 
    <p-column field="citation.citationDesc" header="Citation Desc" [sortable]="true"></p-column> 
    <p-column field="citation.citationObservations" header="Citation Observations" [sortable]="true"></p-column> 
    <p-column field="citation.dateCorrectionReceived" header="Date Correction Received" [sortable]="true"></p-column> 

    <p-column field="citation.inspectionDate" header="Inspection Date" [sortable]="true">  
      <ng-template let-col let-row="rowData" pTemplate="body"> 
       {{row[col.value]}} 
      </ng-template>    
    </p-column> 

    <p-column field="citation.inspectionDate" header="Inspection Date" [sortable]="true"></p-column> 
    <p-column field="citation.inspectionEndDate" header="Inspection End Date" [sortable]="true"></p-column> 
    <p-column field="citation.cfrCiteLang" header="Cfr Cite Lang" [sortable]="true"></p-column>   
    <p-column field="correctionStatus.status" header="Correction Status" [sortable]="true"></p-column> 
    <p-column field="citation.assignment.userId" header="Assigned To" [sortable]="true"></p-column> 
    <p-column field="citation.assignment.dateAssigned" header="Date Assigned" [sortable]="true"></p-column> 
    <p-column field="citation.assignment.percentInterstate" header="% Interstate" [sortable]="true"></p-column> 
    <p-column field="citation.assignment.inspectionalResponsibilty" header="Inspectional Responsibilty" [sortable]="true"></p-column> 
</p-dataTable> 

    import { Citation } from './citation'; 
import { CorrectiveAction } from './corrective-action'; 
import { Operation } from './operation'; 
import { CorrectionStatus } from './correction-status'; 

export interface Observation { 
    id: number; 
    description: string; 
    creatdBy: string; 
    creatdDt: Date; 
    mdfydBy: string; 
    mdfydDt: Date; 
    citation: Citation; 
    correctiveActions: Set<CorrectiveAction>; 
    operation: Operation; 
    correctionStatus: CorrectionStatus; 
} 
    import { RefCd } from './refcd'; 
import { Assignment } from './assignment'; 
import { Operation } from './operation'; 

export interface Citation { 
    id: number; 
    cfrCiteLang: string; 
    citationDesc: string; 
    issueDate: Date; 
    citationShortDescription: string; 
    citationObservations: string; 
    dateCorrectionReceived: Date; 
    inspectionEndDate: Date; 
    inspectionDate: Date; 
    creatdBy: string; 
    creatdDt: Date; 
    mdfydBy: string; 
    mdfydDt: Date; 
    refcd: RefCd; 
    assignment: Assignment; 
    operation: Operation; 
} 

私もこれを試しましたが、何も表示しません。

 <p-column field="citation.inspectionDate" header="Inspection Date" [sortable]="true">  
      <ng-template let-row="rowData" pTemplate="body"> 
       {{row.inspectionDate | date}} 
      </ng-template>    
    </p-column> 

答えて

0
 <p-column field="citation.inspectionDate" header="Inspection Date" [sortable]="true">  
      <ng-template let-row="rowData" pTemplate="body"> 
       {{row.citation.inspectionDate | date}} 
      </ng-template>    
    </p-column> 

これは溶液でした。行には子エンティティが含まれており、そのようにデフリクスする必要がありました。

0
<p-column field="citation.inspectionDate" header="Inspection Date" [sortable]="true">  
     <ng-template let-row="rowData" pTemplate="body"> 
      {{row.inspectionDate | date:'MM/dd/yyyy'}} 
     </ng-template>    
</p-column> 

使うこともできDatePipe

{{row.inspectionDate |日時:詳細については、 'shortDate' '}}

このlink.

ご覧ください
関連する問題