使用与Ember Data的链接

时间:2015-07-26 13:46:34

标签: json ember.js ember-data

我有一个有很多学生的模范教师。我想懒惰学生协会,所以我使用了#34;链接"格式。 一切正常,当我的JSON是:

"links": {
  "students": "/teacher/1/students"
}

但是当我尝试添加" meta"属性:

"links": {
  "students": {
     "href": "/teacher/1/students",
     "meta": 20,
  }
}

我收到错误:

Error while processing route: teacher Assertion Failed: You have pushed a record of type 'teacher' with 'students' as a link, but the value of that link is not a string. Error: Assertion Failed: You have pushed a record of type 'teacher' with 'students' as a link, but the value of that link is not a string.

1 个答案:

答案 0 :(得分:1)

ember-data中的链接上没有meta的概念。您需要修改适配器或序列化程序或将其添加为queryparam。即:

"links": {
  "students": {
     "href": "/teacher/1/students?meta=20"
  }
}