mercredi 28 mars 2018

Accessing Nested JSON in Ember Model

I'm trying to access a particular ID which is nested inside my model to make a belongsTo association. I have no trouble getting what I need in my template, but need image_id within my model. Below is my JSON and current model.

{
  content: {
      title: 'Title',
      header: 'Header',
      image_id: 1
  }
  slug: 'slug',
  title: 'Welcome'
}

Here is my current model...

import DS from 'ember-data';

const { attr } = DS;

export default DS.Model.extend({
  content: attr(),
  title: attr('string'),
});

Hope this makes sense!! Thanks!




Aucun commentaire:

Enregistrer un commentaire