metkappa metkappa - 1 year ago 92
Javascript Question

Ember model result empty in template but filled in inspector

This is my first app in ember.
I have an API url that output this JSON:


App structure:


import DS from 'ember-data';

export default DS.RESTAdapter.extend({
namespace: 'v1',
host: 'http://myhost'


import DS from 'ember-data';

export default DS.Model.extend({
idate: DS.attr('date'),
fdate: DS.attr('date'),
keywords: DS.attr()


import Ember from 'ember';

export default Ember.Route.extend({
model() {
// this not work
return this.get('store').findRecord('search', 123);

// this work
/*return this.get('store').createRecord('search', {
"id": "456",
"idate": "2016-11-24",
"fdate": "2016-12-01",
"keywords": ["ssss", "mmmm"]



<h2>Search page</h2>

{{#each model as |s|}}
<li>id {{}}</li>
<li>idate {{s.idate}}</li>
<li>fdate {{s.fdate}}</li>
<li>keywords {{s.keywords}}</li>


import Ember from 'ember';
import config from './config/environment';

const Router = Ember.Router.extend({
location: config.locationType,
rootURL: config.rootURL
}); {

export default Router;

The problem is that the model seems to be empty in template, but it is filled in inspector.

screenshot of template

Thank you in advance for your support. I'll appreciate every answer.

Answer Source
  • The findRecord method will always return a promise that will be resolved with the record. so instead of each helper you can simply say
  • While including search component don't forget to include model property.
    {{search model=model }}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download