i have an Ember model with a 'hasMany' relation which i don't want to embed, and i need to pass it asynchronously to a component that gets records from the relation. but when i call the component from emblem file (=user-answer userAnswers=userAnswers id=smth.id
), i get an error like "no method 'get' for undefined". here is the code:
app/models/quiz_progress.coffee:
`import DS from "ember-data";`
`import ProgressMixin from "../mixins/progress_mixin"`
QuizProgress = DS.Model.extend ProgressMixin,
userAnswers: DS.hasMany 'user_answer', async: true
`export default QuizProgress;`
app/components/user-answer.coffee:
`import Ember from "ember";`
UserAnswerComponent = Ember.Component.extend
tagName: 'div'
classNames: ['ui', 'list']
userAnswer: (->
id = @get('id')
answers = @get('userAnswers')
answers.findBy('questionId', id).get('answers')
).property('id', 'userAnswers')
`export default UserAnswerComponent;`
and it works only when userAnswers is serialized as embedded. is there really no way to get rid of embedding? i want to pass ids only
Aucun commentaire:
Enregistrer un commentaire