在我的 ember 应用程序中如下图所示,当用户单击发送组件中的操作时,将发送 api post 请求并接收成功数据,可以在 ember 检查器数据选项卡中看到,但我需要刷新页面才能看到新添加的项目,我尝试了 ember 指南中显示的一些示例,没有任何帮助
我的操作代码是
actions:{
send(Text_Message){
if(Text_Message != null){
console.log(this.chatid);
var data = {
"Message" : Text_Message,
"ChatId" : this.chatid
}
var store = this.get('store').createRecord('message',data)
store.save().then((response)=>{
})
}else{
alert("Type something to send")
}
}
}
车把模板是
{{#if messages}}
<div>
{{#each messages as |msg|}}
<div class= {{check msg.SenderId userid }}>
{{msg.Message}}
</div>
{{/each}}
</div>
{{else}}
<div class = "groupmessage-no-Msg">
<div class="groupmessage-msg-content"> No Messages </div>
</div>
{{/if}}
<div class = "groupmessage-msg-control">
{{input type="text" placeholder="Type a Message Here... " value=Text_Message}}
<div {{ action 'send' Text_Message}} class="groupmessage-sendbutton groupmessage-sendbutton1" >Send</div>
</div>