lundi 7 mars 2016

Ember model data not showing up in template

I am building my first ember application and I can't get the model data to go from my songs modal to my songs template...

router.js

import Ember from 'ember';
import config from './config/environment';

const Router = Ember.Router.extend({
  location: config.locationType
});

Router.map(function() {

    this.route('songs'); 
    this.route('song', {path: 'songs/:song_trackId'});
}); 
export default Router;

Here is my songs.js which displays properly

<div>songs</div>

{{#each model as |song|}}
    {{#link-to 'song' song}}
        <img height='100px' width='100px' src = '{{song.artworkUrl100}}'> 
        <div>{{song.trackId}}</div>
    {{/link-to}}
{{/each}}

{{outlet}}

Here is my songs route..

import Ember from 'ember';

var data = {
"results" : [
  {"wrapperType":"track", "kind":"song", "artistId":148662, "collectionId":528436018, "trackId":528437613,......
.
.
. 
]}

export default Ember.Route.extend({
    model: function(){
        return data.results; 
    }
});

Lastly...the song template where the data should go when the user clicks

<div>HI</div>

<div> ArtistId: {{artistId}} </div>
<div> trackId: {{trackId}} </div>
<div> Kind: {{kind}} </div>


{{outlet}}

I dont think the link-to is setup improperly. Am I referencing the dynamic song incorrectly in the router?




Aucun commentaire:

Enregistrer un commentaire