EmberJS - {{moment-format 'date' 'output' 'input'}} 在 {{#each} 块中使用时在每一行中重复今天的日期
EmberJS - {{moment-format 'date' 'output' 'input'}} repeats todays date in every row when used in {{#each} block
我正在使用 ember-moment 插件来格式化以下 table 中的日期:
<tbody>
{{#each model as |model|}}
<tr class="clickable-row">
<td>{{model.id}}</td>
<td>{{model.first_name}}</td>
<td>{{model.last_name}}</td>
<td>{{model.date_of_birth}}</td>
<td>{{model.inserted_at}}</td>
<td>{{model.departed_at}}</td>
</tr>
{{/each}}
</tbody>
date_of_birth
属性 从 DB 返回的 ha 格式如下:
yyyy-mm-ddThh:mm:ss+|-hhmm
当我尝试像下面这样格式化它时;
{{moment-format 'model.date_of_birth' 'DD/MM/YYYY' 'yyyy-mm-ddThh:mm:ss+|-hhmm' }}
我最终得到了一个 table 充满唯一行的填充,除了出生日期在每一行上都是今天的日期。
我知道我遗漏了一些明显的东西,外面的人会让我看起来很傻!
您应该将绑定日期对象传递给助手,而不是将其名称作为字符串传递。因此像这样使用它:
{{moment-format model.date_of_birth 'DD/MM/YYYY' }}
我正在使用 ember-moment 插件来格式化以下 table 中的日期:
<tbody>
{{#each model as |model|}}
<tr class="clickable-row">
<td>{{model.id}}</td>
<td>{{model.first_name}}</td>
<td>{{model.last_name}}</td>
<td>{{model.date_of_birth}}</td>
<td>{{model.inserted_at}}</td>
<td>{{model.departed_at}}</td>
</tr>
{{/each}}
</tbody>
date_of_birth
属性 从 DB 返回的 ha 格式如下:
yyyy-mm-ddThh:mm:ss+|-hhmm
当我尝试像下面这样格式化它时;
{{moment-format 'model.date_of_birth' 'DD/MM/YYYY' 'yyyy-mm-ddThh:mm:ss+|-hhmm' }}
我最终得到了一个 table 充满唯一行的填充,除了出生日期在每一行上都是今天的日期。
我知道我遗漏了一些明显的东西,外面的人会让我看起来很傻!
您应该将绑定日期对象传递给助手,而不是将其名称作为字符串传递。因此像这样使用它:
{{moment-format model.date_of_birth 'DD/MM/YYYY' }}