jeudi 9 mars 2017

Work with data before return it in Ember.js

I'm trying to build a chart using Google Chart in Ember.js but I'don't know how to deal with data in the route/controller before returning the data to the view...

Indeed I need to transform my object into an array for Google Chart.

Is it even possible to do that with Ember.js ?

import Ember from 'ember';

export default Ember.Route.extend({
    model() {
        this.store.findAll('rate').then(data => {
            console.log(data);
        });
        return [
            ['Task', 'Hours per Day'],
            ['Work', 11],
            ['Eat', 2],
            ['Commute', 2],
            ['Watch TV', 2],
            ['Sleep', 7],
        ];
    }
});

I want to return data from my rate store instead of hard coded values.




Aucun commentaire:

Enregistrer un commentaire