2016-06-12 2 views
1

this.store.findAll('podcast') gibt URLs an Podcast-Feeds zurück. Ich möchte eine Anfrage in setupController stellen, um die /feed von URLs zu erhalten. Ist es überhaupt möglich?Ember setupController-Anforderung

Antwort

1

Sicher nur native jQuery AJAX-Aufrufe verwenden. Etwas wie folgt aus:

Strecke

import Ember from 'ember'; 

export default Ember.Route.extend({ 
    model: function(){ 
     return this.store.findAll('podcast') 
    }, 

    setupController(controller, model) { 
     controller.set('podcastFeeds', []); 

     model.forEach(podcast => { 
      Ember.$.ajax({ 
       url: podcast.get('feed'), // get the property 
      }).then(feedData => { 
       controller.get('podcastFeeds').addObject(feedData); 
      },() => { 
       //handle error 
      }); 
     }); 
    } 
}); 

Vorlage

{{#each podcastFeeds as |podcastFeed|}} 
    {{{podcastFeed}}} 
{{/each}}