samedi 27 février 2016

Problems retrieving data from controller using Ember.js

I am trying to learn ember following this course and I have the follwoing controller

import Ember from 'ember';

export default Ember.Controller.extend({
  title:'My Blog Post',
  body:'Body of the post',
  authors:['Author1', 'Author2', 'Author3'],
  comments:[
    {
      name:'name 1',
      comment:'comment 1'
    },
    {
      name:'name 2',
      comment:'comment 2'
    },
    {
      name:'name 3',
      comment:'comment 3'
    }
  ]
});

And Template:

<h1>{{title}}</h1>
<p>{{body}}</p>
<p>
  <strong>Authors:</strong>
  {{#each authors}}
    {{this}},
  {{/each}}
</p>
<h4>Comments</h4>
<ul>
{{#each comments as c}}
  <li><strong>{{name}}</strong> - {{comment}}</li>
{{/each}}
</ul>

And it has been generating this output:

My Blog Post

Body of the post

Authors: <my-app@controller:post::ember424>, <my-app@controller:post::ember424>, <my-app@controller:post::ember424>,

Comments

 -
 -
 -

I double check everything and it is identical to the demo I am seem, I also try to use {{each authors as author}} {{this.author}}, try to use {{c.name}}, also try {{this.name}}, {{this.c.name}}

Any ideas where I am going wrong?

Thanks in advance




Aucun commentaire:

Enregistrer un commentaire