作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
{{cell | filesize}}和 dateFormat看起来像这样 dateFormat(r-6ren">
假设我在 html 中有 *ngFor="let cell of dateFormat(row)">{{cell | filesize}}</td>
和 dateFormat
看起来像这样
dateFormat(row:string){
var today = new Date(row[4]);
let latest_date = this.datepipe.transform(today, 'yyyy-MM-dd');
row['4'] = latest_date;
return row;
}
HTML:
<tr *ngFor="let row of this.UploaderService.tableData2.dataRows">
<td [ngClass]="{'active': check(row) }" (click)="listClick($event, row)"
(dblclick)="listDoubleClick($event, row)"
*ngFor="let cell of dateFormat(row)">{{cell}}
</td>
</tr>
有没有办法调用filesize仅在 row['2']
?此刻filesize工作正常,但它会格式化所有行。我试过 dateFormat
但我不确定如何使用 filesize
在 typescript 中。像这样
let latest_date = this.datepipe.transform(today, 'yyyy-MM-dd');
row['4'] = latest_date;
row['2'] = here convert row['2'] using filesize;
return row;
有什么想法吗?
最佳答案
npm install ngx-filesize
在你的模块中:
import {NgxFilesizeModule} from 'ngx-filesize';
// ...
@NgModule({
// ...
imports: [
// ...
NgxFilesizeModule,
// ...
]
// ...
})
在你的组件中
{{bytes | filesize}}
*我知道这个解决方案是一个迟到的回复,但它可以帮助即将到来的开发人员:)
关于angular - 我如何在 Angular 6 中以人类可读的方式表示文件大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53031243/
我是一名优秀的程序员,十分优秀!