Last active
August 29, 2015 13:57
-
-
Save bagby/9450322 to your computer and use it in GitHub Desktop.
{{each}} of computed property
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
models: | |
App.Lesson = DS.Model.extend({ | |
contentCards: DS.hasMany('contentCard', { async: true }), | |
learningObjectives: function() { | |
return this.get('contentCards') | |
.mapBy('assignedLearningObjectives') | |
.flatten() | |
.mapBy('learningObjective') | |
.uniq() | |
.sortBy('sortOrder'); | |
}.property().volatile() // yes it has come to this | |
}); | |
App.ContentCard = DS.Model.extend({ | |
lesson: DS.belongsTo('lesson'), | |
assignedLearningObjectives: DS.hasMany('assignedLearningObjective', { async: true }) | |
}); | |
App.AssignedLearningObjective = DS.Model.extend({ | |
contentCard: DS.belongsTo('contentCard'), | |
learningObjective: DS.belongsTo('learningObjective') | |
}); | |
App.LearningObjective = DS.Model.extend({ | |
assignedLearningObjectives: DS.hasMany('assignedLearningObjective', { async: true }) | |
}); | |
template: | |
{{#each learningObjective in view.lesson.learningObjectives}} | |
{{learningObjective.title}} | |
{{/each}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment