lundi 21 mars 2016

ember simple index route not ddisplaying array items

Learning Ember.js , I am trying to replicate the examples from Ember.js book I am using the latests stable ember-cli v 2.4.2.

$ ember server
version: 2.4.2
Livereload server on http://localhost:49152
Serving on http://localhost:4200/

Build successful - 3979ms.

All my 'project' fuils are generated with ember new 'project', like

project/app/app.js

import Ember from 'ember';
import Resolver from './resolver';
import loadInitializers from 'ember-load-initializers';
import config from './config/environment';
let App;
Ember.MODEL_FACTORY_INJECTIONS = true;
App = Ember.Application.extend({
  modulePrefix: config.modulePrefix,
  podModulePrefix: config.podModulePrefix,
  Resolver
});
loadInitializers(App, config.modulePrefix);
export default App;

project/app/router.js

import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
  location: config.locationType
});
Router.map(function() {
});
export default Router;

I updated some files , like :

project/app/templates/index.hbs

Hi, this is {{name}}.
I like the following colors.
<ul>
    {{#each item in model}}
        <li>{{item}}</li>
    {{/each}}
</ul>

project/app/controllers/index.js

import Ember from 'ember';
export default Ember.Controller.extend({
    name: "John Doe"
});

project/app/routes/index.js

import Ember from 'ember';
export default Ember.Route.extend({
  model: function() {
    return ['red', 'yellow', 'blue'];
  }
}); 

running the project with ember server should display :

Welcome to Ember.js
Hi, this is John Doe. I like the following colors.
 - red
- yellow
- blue
©2014 Ember.js Essentials

But I don't get the color list at all ... I only get :

Welcome to Ember.js
Hi, this is John Doe. I like the following colors.

©2014 Ember.js Essentials

What did I missed ?

thanks for enlightments




Aucun commentaire:

Enregistrer un commentaire