lundi 25 juillet 2016

Chunk Ember Model Array

I am trying to split up the model array of controller to make it easier to display but the approach I came up with is not right. How do I access the model array of a controller so that it can be manipulated and still maintain computed properties of the model?

Controller:

export default Ember.Controller.extend({

  queryParams: ['page'],
  page: "",

  playlists: Ember.computed("model", function(){
    var playlistContent = this.get("model.content");
    return _.chunk(playlistContent, 3);
  }),

  actions: {
    setPage(page){
    this.set("page", page);
  }
});

Template:


  <div class="row">
    
        <div class="col-md-4">
            <div class="card playlist-card">
                <img class="card-img-top" src= alt="Card image cap">
                <div class="card-block">
                    <h4 class="card-title"></h4>
                    <p class="card-text"></p>
                </div>
            </div>
        </div>
    
  </div>





Aucun commentaire:

Enregistrer un commentaire