我正在从API接收18个属性,我需要为两个属性值应用日期管道。我该如何申请18个属性中的.ts
文件。
在代码下面,
return {
prop: i,
index: index,
};
给所有财产。并返回_cols,我需要为两个字段应用日期管道以使日期成为美国格式。
这是.ts
文件:
private getStatusSummary(clearCache?: boolean) {
this.loaderService.startLoader(this.loader.id);
let params = {
reportname: 'getscriptstatusdisplay',
fromDate: '',
toDate: ''
};
params = merge({}, params, this.filters);
this.httpClient
.cache(clearCache)
.get(`/${API.sourceStatusSummary}`, {
params: params
})
.subscribe(
(data: any) => {
this.loaderService.stopLoader(this.loader.id);
const error = get(data, 'errorMessage', '');
const records = get(data, 'body', []);
if (error) {
} else {
this.rows = records;
let _cols =
isArray(this.rows) && this.rows.length > 0
? Object.keys(get(this.rows, '[0]')).map((i, index) =>
{
return {
prop: i,
index: index,
};
})
: [];
this.tempRows = records;
this.columns = _cols;
this.allColumns = _cols;
this.columns.push({
prop: 'Action',
index: this.columns.length,
width: 100,
resizeable: false,
sortable: false,
cellTemplate: this.actionTemplate
});
this.setError('');
}
},
error => {
this.loaderService.stopLoader(this.loader.id);
this.setError(error);
}
);
}
HTML代码:
<ngx-datatable
[rows]="rows"
[rowHeight]="'auto'"
[scrollbarH]="true"
class="bootstrap"
[columnMode]="'force'"
[reorderable]="'false'"
[headerHeight]="50"
[footerHeight]="50"
[limit]="ITEM_PER_PAGE"
[hidden]="rows.length === 0"
#table
>
<ngx-datatable-column
[resizeable]="false"
*ngFor="let col of columns;"
[prop]="col.prop"
[cellTemplate]="col.cellTemplate"
[maxWidth]="col.maxWidth"
>
</ngx-datatable-column>
我需要将date属性显示为US(07-16-1997)formate,因为它现在是1997-07-16T19:20:30.45 + 01:00]
我正在从API接收18个属性,我需要为两个属性值应用日期管道。我如何在18个属性中的.ts文件中应用。在下面的代码中,返回{prop:i,index:...
应该很简单,只需将要应用到该列的数据传递给管道: