如何更改 .hbs 文件中的值
How do I change a value in a .hbs file
posts.hbs
我想为 "onePost.id" 值添加后缀,必须在此文件中完成。
<br>
<h2> Blog Posts </h2>
<ul>
{{#each model as |onePost index|}}
<li id = {{index}}>{{onePost.title}} {{edit-post id = onePost.id + 'suffix' }}
</li><br>
{{/each}}
</ul>
{{add-new-post}}
使用 concat
模板助手:
<li id={{index}}>{{onePost.title}} {{edit-post id=(concat onePost.id 'suffix')}}
posts.hbs
我想为 "onePost.id" 值添加后缀,必须在此文件中完成。
<br>
<h2> Blog Posts </h2>
<ul>
{{#each model as |onePost index|}}
<li id = {{index}}>{{onePost.title}} {{edit-post id = onePost.id + 'suffix' }}
</li><br>
{{/each}}
</ul>
{{add-new-post}}
使用 concat
模板助手:
<li id={{index}}>{{onePost.title}} {{edit-post id=(concat onePost.id 'suffix')}}