Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4828

Restructure data before output in template

$
0
0

@celo wrote:

Guys, i'm using this ember-full-calendar add-on and i need re-structure my data because in the currently format full calendar can't read it.

I'm doing this:

First i'm returning all my events in the route:

export default Route.extend({
  model() {
    return this.store.findAll('event');
  }
});

After, i'm using my controller to adapt my events:

  events: [],

  eventsObs: observer('model', function() {
    let events = [];

    this.get('model').forEach((item) => {
      events.pushObject({
        id    : item.id,
        title : item.get('title'),
        start : item.get('start'),
        end   : item.get('end')
      })
    });

    this.set('events', events);
  })

And finally i can call full-calendar component:

{{full-calendar events=events lang="pt-br"}}

I have the impression that the Ember can help me better. Could you give me a hand , maybe some tips?

Thank you!

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4828

Trending Articles