vendredi 31 mars 2017

Error while trying to self reference a model in ember.js

I'm trying to create a self-referenced property in a model, but I'm getting the following error:

Error while processing route: index No model was found for 'menu' Error

Here is my model (menus.js):

import DS from 'ember-data';

export default DS.Model.extend({    
  title: DS.attr('string'),
  link: DS.attr('string'),
  isActive: DS.attr('boolean'),
  children: DS.hasMany('menus', { inverse: null }),
});

I'm trying to returning a list from a Web API. Here is my API JSON return:

[
  {
    "id": 1,
    "title": "Test",
    "link": "index",
    "isActive": false,
    "children": [
      {
        "id": 4,
        "title": "Test 2",
        "link": "index",
        "isActive": false
      }
    ]
  },
  {
    "id": 2,
    "title": "Test 2",
    "link": "index",
    "isActive": false,
    "children": [
      {
        "id": 5,
        "title": "Test 4 ",
        "link": "index",
        "isActive": false
      }
    ]
  },
  {
    "id": 3,
    "title": "Test 5",
    "link": "index",
    "isActive": false,
    "children": [
      {
        "id": 6,
        "title": "Test 6",
        "link": "index",
        "isActive": false
      },
      {
        "id": 7,
        "title": "Test 7",
        "link": "index",
        "isActive": false
      }
    ]
  }
]




Aucun commentaire:

Enregistrer un commentaire