Ember.js 如何获得模型';安伯的身份证是什么?

Ember.js 如何获得模型';安伯的身份证是什么?,ember.js,Ember.js,我有一个定义如下的模型: App.Product = DS.Model.extend({ name: DS.attr('string'), price: DS.attr('number') }); REST端点成功地返回了产品,但是,尽管还返回了一个名为“id”的字段,该字段在名称和价格旁边包含一个整数,但它不允许我检索此id product1 = this.store.find('Product', 1); console.log(product1.get('name');

我有一个定义如下的模型:

App.Product = DS.Model.extend({
    name: DS.attr('string'),
    price: DS.attr('number') 
});
REST端点成功地返回了产品,但是,尽管还返回了一个名为“id”的字段,该字段在名称和价格旁边包含一个整数,但它不允许我检索此id

product1 = this.store.find('Product', 1);
console.log(product1.get('name'); // successful
console.log(product1.get('id'); // undefined
(我尝试添加
id:DS.attr('number')
,但Ember不允许这样做。)

我遗漏了什么?

find
是:您应该能够像这样检查id:

promise = this.store.find('product', '1').then(function(product) {
  console.log(product.get('id'));
});
另外,请确保您没有将适配器的
primaryKey'属性更改为除
id`以外的其他属性。

find
is:您应该能够像下面这样检查id:

promise = this.store.find('product', '1').then(function(product) {
  console.log(product.get('id'));
});
另外,请确保您没有将适配器的
primaryKey'属性更改为除
id`以外的其他属性。

find
is:您应该能够像下面这样检查id:

promise = this.store.find('product', '1').then(function(product) {
  console.log(product.get('id'));
});
另外,请确保您没有将适配器的
primaryKey'属性更改为除
id`以外的其他属性。

find
is:您应该能够像下面这样检查id:

promise = this.store.find('product', '1').then(function(product) {
  console.log(product.get('id'));
});
还要确保您没有将适配器的
primaryKey'属性更改为除
id`以外的其他属性