【问题标题】:why doesnt print property file.lastModifiedDate of file?为什么不打印文件的属性 file.last 修改日期?
【发布时间】:2017-12-31 04:22:38
【问题描述】:
<tr *ngFor="let file of filesList; let i=index">
      <td><input class="form-control input-sm" value="{{ file.url }}"/></td>
      <td>{{ file.size/1024 | round }} Kb</td>
      <td>{{ file.lastModifiedDate }} </td>
</tr>

我看到文件在控制台日志中有这个属性,我该如何打印它?

【问题讨论】:

    标签: javascript angular file-upload angular2-forms last-modified


    【解决方案1】:

    Date Pipe会帮你,请看下面:

    <td>{{file.lastModifiedDate | date}}</td>
    

    这将格式化您的日期,请参阅上面的链接了解不同的格式

    【讨论】:

    • 请问,使用多个管道指令是不是一种不好的做法?例如我以前用圆管
    • 不,不是 - 管道可以使用:)
    • 并且,抱歉,我需要创建一个新的“date.pipe.ts”,然后从“@angular/core”导入 {Pipe, PipeTransform};再次?就像它在我的 round.pipe.ts 中一样,然后又包含在 AppModule 中?
    • 这无济于事。如果我设置 '{{file.lastModifiedDate | date }} ' - 它仍然没有打印。我还包括 'import { DatePipe } from '@angular/common';'在 app.module 中以及在 NgModule 中设置时 - CommonModule 有错误 - “找不到名称'CommonModule'。”
    • 我试过了 - 没有。我的行为是否正确包括管道?
    【解决方案2】:

    我找到了:

    虽然文件 API 规范的早期草案中存在此属性,但该属性已从中删除,现在是非标准的。请改用 File.lastModified。

    &lt;td&gt;{{ file.modified * 1000 | date:'MM-dd-yyyy' }} &lt;/td&gt; 它帮助了我

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-21
      • 2016-06-24
      • 1970-01-01
      相关资源
      最近更新 更多