ember.js是否支持段文字表示法?

时间:2014-11-18 05:06:43

标签: ember.js

Ember.js似乎不支持在对象属性名称中带点的json对象(例如):

{“ns1.id”:14,“ns2.name”:“mike”};

这是遗漏还是我忽略了什么?我们需要以这种方式使用支持命名空间的服务。

Handlebars似乎支持使用segment-literal表示法(例如{{[nd.id]}})。 Ember也是如此吗?我错过了哪些文件?

谢谢!

1 个答案:

答案 0 :(得分:-1)

是的,你可以这样做。 compound documents用于保存HTTP请求,可以方便地将相关文档与请求的文档一起发送。

在这种情况下,每个关系的一些额外元数据可以将文档链接在一起。以下示例显示了复合文档的使用:

{
  "rels": {
    "posts.author": {
      "url": "http://example.com/people/{post.author}",
      "type": "people"
    },
    "posts.comments": {
      "url": "http://example.com/comments/{post.comments}",
      "type": "comments"
    }
  }
  "posts": [{
    "id": 1,
    "title": "Rails is Omakase",
    "rels": {
      "author": 9,
      "comments": [ 1, 2, 3 ]
   }, {
    "id": 2,
    "title": "The Parley Letter",
    "rels": {
      "author": 9,
      "comments": [ 4, 5 ]
   }, {
    "id": 1,
    "title": "Dependency Injection is Not a Virtue",
    "rels": {
      "author": 9,
      "comments": [ 6 ]
    }
  }],
  "people": [{
    "id": 9,
    "name": "@d2h"
  }],
  "comments": [{
    "id": 1,
    "body": "Mmmmmakase"
  }, {
    "id": 2,
    "body": "I prefer unagi"
  }, {
    "id": 3,
    "body": "What's Omakase?"
  }, {
    "id": 4,
    "body": "Parley is a discussion, especially one between enemies"
  }, {
    "id": 5,
    "body": "The parsley letter"
  }, {
    "id": 6,
    "body": "Dependency Injection is Not a Vice"
  }]
}