0
posts.hbsのインデックス値をdelete-post.hbsに渡し、次にdelete-post.hbsからmy delete-post.jsに渡そうとしています関数。1つの.hbsファイルから別の.hbsファイルに値を渡す方法
posts.hbs
<br>
<h2> Blog Posts </h2>
<ul>
{{#each model as |onePost index|}}
<li id = {{index}}>{{onePost.title}} {{delete-post}}
</li><br>
{{/each}}
</ul>
{{add-new-post}}
削除-post.hbs
<a class="ui red button" {{action 'deletePost' parentNode.id `}}>Delete</a>`
削除-post.js
import Component from '@ember/component';
export default Component.extend
({
actions:
{
deletePost(input)
{
alert(input);
}
}
});
に
parentNodeId
にparentNode.id
を変更する必要があり、それはそれを聞いて幸せ – AmmarMZ@AmmarMZを、働いていました。私の答えの左側にある目のアイコンをクリックして答えを受け入れることができます。 –
posts.hbsで直接parentNodeIdを編集する方法を知っていますか?たとえば、次のように番号1を追加したいとします。parentNodeId = index + '1' – AmmarMZ