dimanche 5 juillet 2015

Ember JS The value that #each loops over must be an Array

Fairly new to ember js and I've encountered this error.

Error: Assertion Failed: The value that #each loops over must be an Array. You passed '[Saab,Volvo,BMW]' (wrapped in (generated favorites controller))

On my route/favorites.js

export default Ember.Route.extend({
  model: function() {
    // the model is an Array of all of the posts
    // fetched from this url

      var cars = ["Saab", "Volvo", "BMW"];
    return cars;
  }
});

That's the only line from my route/favorite.js

and on my app/router.js

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

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

Router.map(function() {
  this.route('favorites');
});

export default Router;

and my favorites.hbs

<h1>{{appName}}</h1>

<ul>
{{#each controller as |item|}}
  <li>{{item}}</li>
{{/each}}
</ul>

What am I missing?




Aucun commentaire:

Enregistrer un commentaire