【发布时间】:2017-08-26 05:44:21
【问题描述】:
我正在尝试在模型中创建自引用属性,但出现以下错误:
处理路由时出错:index No model were found for 'menu' Error
这是我的模型(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 }),
});
我正在尝试从 Web API 返回一个列表。这是我的 API JSON 返回:
[
{
"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
}
]
}
]
【问题讨论】:
标签: javascript c# json asp.net-web-api ember.js