Javascript 余烬数据加载到存储区,赢得';我没有出现在第页上

Javascript 余烬数据加载到存储区,赢得';我没有出现在第页上,javascript,ember.js,handlebars.js,Javascript,Ember.js,Handlebars.js,我有一个连接到单独phoenix API的ember应用程序。我使用的是ActiveModelAdapter,在我将ember版本升级到2.1.0之前,一切都很正常。现在,数据将加载到存储中,但不会显示在页面上。我的浏览器控制台没有抛出任何错误,我只是在这一点上被难住了。我以前从未使用过这个版本的余烬,因此任何指向正确方向的指针都将不胜感激 我的适配器: # app/adapters/application.js import DS from 'ember-data'; import Acti

我有一个连接到单独phoenix API的ember应用程序。我使用的是
ActiveModelAdapter
,在我将ember版本升级到2.1.0之前,一切都很正常。现在,数据将加载到存储中,但不会显示在页面上。我的浏览器控制台没有抛出任何错误,我只是在这一点上被难住了。我以前从未使用过这个版本的余烬,因此任何指向正确方向的指针都将不胜感激

我的适配器:

# app/adapters/application.js

import DS from 'ember-data';
import ActiveModelAdapter from 'active-model-adapter';

export default ActiveModelAdapter.extend({
 namespace: 'v1',
 host: 'http://localhost:4000'
});
我的路由器:

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

var Router = Ember.Router.extend({  
location: config.locationType
});

export default Router.map(function() {  
  this.route('resources', function() {
    this.route('new');
    this.route('resource', { path: '/:resource_id' });
    });
});
我的模型:

import DS from 'ember-data';

export default DS.Model.extend({  
  title: DS.attr('string'),
  description: DS.attr('string'),
  url: DS.attr('string'),
  topic: DS.attr('string')
});
我的控制器:

import Ember from 'ember';

export default Ember.Controller.extend({
  actions: {
  editResource: function() {
    this.toggleProperty('isEditing');
  },
  saveResource: function() {
    var resource = this.get('model');
    resource.save();
    this.toggleProperty('isEditing');
    }, 
  },

  isEditing: false
});
列出所有资源的索引页的我的模板:

<div class="container col-md-6 col-md-offset-3">
  <ul class="list-group">
    {{#each resource in model}}
     <li class="list-group-item active">
      {{#link-to 'resources.resource' resource}}
         <h5>{{resource.title}}</h5> 
     {{/link-to}}</li>
     <li class="list-group-item"><p>topic: {{resource.topic}}</p></li>
     <li class="list-group-item"><p>url: {{resource.url}}</p></li>
    {{/each}}
  </ul>
</div>

    {{{#模型中的每个资源}
  • {{{#链接到'resources.resource'resource}} {{resource.title} {{/链接到}
  • 主题:{{resource.topic}

  • url:{{resource.url}

  • {{/每个}}
这是当我尝试访问我的索引页route:localhost:4200/resources时在浏览器控制台中看到的

在ember data inspector中,有我的四个资源,但页面上没有显示。同时,控制台中没有错误

再次感谢您的帮助。谢谢

另外,如果有人对我的回购协议感兴趣,我正在从事的分支是单元测试:

更新:由于@dfreeman,我的索引模板现在可以正确呈现,但用于呈现单个模型对象的显示页面仍然为空:

<div class="well col-sm-4 col-sm-offset-4" style="text-align: center;"        {{bind-attr class="resource.isShowing:show resource.isEditing:editing"}}>

{{#if model.isEditing}}
  <input class="edit">{{model.title}}  
  <p class="edit" >{{model.url}}</p> 
  <p class="edit" >topic: {{model.topic}}</p> 
  <p class="edit" >description: {{model.description}}</p>   
{{else}}
  <h4 class="toggle" {{action "editResource" on="doubleClick"}}>      {{model.title}}</h4>  
  <p class="toggle" {{action "editResource" on="doubleClick"}}>   {{model.url}}</p> 
  <p class="toggle" {{action "editResource" on="doubleClick"}}>topic:   {{model.topic}}</p> 
  <label class="toggle" {{action "editResource" on="doubleClick"}}>description: {{model.description}}</label>
  {{/if}}
  <p>{{#link-to 'resources.resource.edit' model}}Edit{{/link-to}}</p> 
</div>

{{{#if model.isEditing}
{{model.title}}

{{model.url}

主题:{{model.topic}

描述:{{model.description}}

{{else} {{model.title}}

{{model.url}}

topic:{{model.topic}

描述:{{model.description}} {{/if} {{{#链接到'resources.resource.edit'model}}编辑{{/link to}}

每个助手的
{{{#每个x在y}}
版本都是。早在1.10中,就引入了a来代替它

如果您更改了模板以使用新语法,您应该可以很好地使用

{{#each model as |resource|}}
  ...
{{/each}}
{{{#每个x在y}}
版本的
每个
帮助程序都是。早在1.10中,就引入了a来代替它

如果您更改了模板以使用新语法,您应该可以很好地使用

{{#each model as |resource|}}
  ...
{{/each}}

谢谢@dfreeman!我的索引页现在正在正确呈现,但用于呈现单个资源对象的显示页仍然为空。有什么想法吗?我将复制并粘贴上述原始问题底部的模板。@SophieDeBenedetto您的
资源。hbs
必须有一个
{{outlet}
来呈现嵌套路由的内容。检查一下这个谢谢@dfreeman!我的索引页现在正在正确呈现,但用于呈现单个资源对象的显示页仍然为空。有什么想法吗?我将复制并粘贴上述原始问题底部的模板。@SophieDeBenedetto您的
资源。hbs
必须有一个
{{outlet}
来呈现嵌套路由的内容。选中此选项,您的
show
模板中的
bind attr
仍然绑定到“resource.isShowing”,我想您可能想要“model.isShowing”?另外,您可以摆脱
bind attr
,应该使用绑定动态内容的更新方法-您在
show
模板中的
bind attr
仍然绑定到“resource.isShowing”,我想您可能想要“model.isShowing”?此外,您还可以摆脱
bind attr
,并应使用绑定动态内容的更新方法-