彼はit.Howeverユーザーがすべてのposts.The JavaScriptコードを見ることができます投稿1だった場合、ユーザーにのみ投稿を削除することができますは次のとおりです。Blazeで平等をチェックしていますか?
var postedBy = Meteor.user();
var currentPost = this._id;
Posts.insert({
name:postName,
createdAt:new Date(),
postId:currentPost,
postedBy:postedBy
});
HTMLコードは次のとおりです。
<template name="posts">
{{#if currentUser}}
{{> addPost}}
<ul>
{{#each post}}
<li>{{> postItem}}</li>
{{/each}}
</ul>
{{/if}}
</template>
<template name="postItem">
<li>
<h4>{{name}}</h4>
<i>Posted by {{postedBy.username}} on {{createdAt}}</i>
[<a href="#" class="delete-post">Delete</a>]
</li>
</template>
<template name='addPost'>
<input type='text' placeholder='Add post here' name='postName' id ='myinput'>
<button class="btn btn" type="button" id='btn'>Post</button>
</template>
currentUser.usernameとpostedBy.usernameの両方に、ログインしたユーザーと特定の投稿をそれぞれ投稿したユーザーの名前が表示されます。
私はDelete anchorタグで作業しようとしています。
{{#if currentUser.username==postedBy.username}}
[<a href="#" class="delete-post">Delete</a>]
{{/if}}
しかし、それは、コマンドprompt.Iの誤差が、それは間違っている知っている示していますが、私は、現在のユーザーが1つだったかどうかをチェックするためにこの「もし」ステートメントを書くのですway.How私は他を考えることができない人この投稿を投稿しましたか? 私はMeteorに慣れています。英語は悪いです。
ありがとうございます。私はこれを念頭に置いています。 –