0

私は Ember の初心者で、Ember/Rails アプリケーションで動作するように警告を表示するのに苦労しています。スコープの問題があり、処理方法がよくわからないと思います..

コントローラー内には、次のコードを含む削除アクションがあります。

swal({
  title: "Are you sure?"
  text: "You will not be able to recover this post!"
  type: "warning"
  showCancelButton: true
  confirmButtonColor: "#DD6B55"
  confirmButtonText: "Yes, delete it!"
  closeOnConfirm: false
}, ->
  @get('model').destroyRecord().then =>
    @transitionToRoute 'posts'
  swal("Deleted!", "Your post has been deleted.", "success")

)

エラーを '@get('model').destroyRecord().then' までたどると、コントローラー アクション内の関数内で 'this.get' を呼び出しているためだと確信しています。ただし、それを修正する方法がわかりません...関数内でコントローラーを参照するにはどうすればよいですか? これを修正する方法、または同じ機能を実現するためのより良い方法に関する提案はありますか?

4

2 に答える 2