I am trying to use the binding data in an ember application created with cli. I can not find my data. The inspector shows that I have a model called post, but nothing in it. I am not sure why it does not work, so I am sending files that, in my opinion, are relevant ...
models / post.js
var Post = DS.Model.extend({ title: DS.attr('string'), content: DS.attr('string'), publishDate: DS.attr('date') }); Post.reopenClass({ FIXTURES: [ { id: 1, title: "Writing a blog in Ember", content: "I am writting a blog", publishDate: "05/22/2104" }, { id: 2, title: "Writing a blog in Ember", content: "I am writting a blog", publishDate: "05/22/2104" } ] }); export default Post;
router.js
var Router = Ember.Router.extend({ location: ENV.locationType }); Router.map(function() { this.resource('posts', { path: '/' }); }); export default Router;
routes / index.js
export default Ember.Route.extend({ model: function() { return this.store.find('post'); } });
Controllers / posts.js
var PostsController = Ember.ArrayController.extend({ }); export default PostsController;
Templates / posts.hbs
<p>Test</p> <ul> {{#each}} <li> {{title}} </li> {{/each}} </ul>
I think this problem is specific to ember-cli. I have tools that work with the Ember App Kit, but you want to work with ember-cli. I added an adapter and tried to change the way the fixtures are mounted:
adapters / post.js
var PostAdapter = DS.FixtureAdapter.extend({}); export default PostAdapter;
Modified models /post.js
var Post = DS.Model.extend({ title: DS.attr('string'), content: DS.attr('string'), publishDate: DS.attr('date') }); Post.FIXTURES = [ { id: 1, title: "Writing a blog in Ember", content: "I am writting a blog", publishDate: "05/22/2104" }, { id: 2, title: "Writing a blog in Ember", content: "I am writting a blog", publishDate: "05/22/2104" } ]; export default Post;
This still does not work. The Ember inspector shows messages with the correct fields (id, title, content publishDate), but not the actual data.