如何将请求发送到服务器以获取 ember 中模式对话框的数据

How to send the requests to server to get the data for my modal dialog in ember

我在我的 app.Now 中使用 ember-modal-dialog 插件作为对话框功能,每次我点击按钮时,对话框中显示的数据都是从 server.So 请求的请求服务器并显示接收到的数据。

feed.hbs

{{#each feedResult as |feed|}}

<p {{action "toggleModal" feed.fivers_pk }}> {{feed.numFives}} </p>
   {{#if isShowingModal}}
       {{#modal-dialog close="toggleModal"}}
           <p>People who Hi-Fived this</p>
           <img src = "images/shape-line-separator.png">

                 Data from server

       {{/modal-dialog}}
   {{/if}}

{{/each}

Controller.js(feed.js)

import Ember from 'ember';
import raw from 'ic-ajax';

const { service } = Ember.inject;

export default Ember.Controller.extend({
     session:service('session'),
     isShowingModal: false,
     fivers:[],
     feedResult:Ember.computed('model',function() {

            SOME MANIPULATION WITH DATA
     }),

     actions:{

      toggleModal: function(fiverpk) {
         this.toggleProperty('isShowingModal');
         console.log(fiverpk);
         raw({
            url: "http://example.com/api/photos/"+fiverpk+"/fivers/",
            type: 'GET',
        });
  }, 
}
});

我可以向服务器发出请求并通过 actions.But 中的 ajax 调用接收数据 我应该在哪里以及如何存储 it.So 我可以在模态中使用它-打开时的对话框。

您对 AJAX 请求的返回结果不做任何处理。你可以做类似下面的事情

raw({
    url: "http://example.com/api/photos/"+fiverpk+"/fivers/",
    type: 'GET',
}).then(function(result) {
   // add the relevant part of the result to the modal
});