vendredi 29 avril 2016

Create Child Records in hasMany Relationship with Ember.Js

First time using Ember.

I have two models one is post model and another is comments model

export default DS.Model.extend({
  postName: DS.attr('string'),
  postedDate: DS.attr('string'),
  postcontent: DS.attr('string'),
  comments: DS.hasMany('comment', {async : true})
});

export default DS.Model.extend({
  comments: DS.attr('string'),
  post: DS.belongsTo('post')
});

In the post home page, I will fetch the metaInfo of post like postName and postedDate using this.store.peekAll('post') now ember data is updated with post metaInfo postName and postedDate, I will not load comments.

When the user clicks on the post I have to get the content of the post and display the post content.

when the user clicks on the comment section, I have to get 10 comments among 100 comments.

How could I do this please help me out on this.

Grateful for any assistance!




Aucun commentaire:

Enregistrer un commentaire