After searching through numerous examples on Stackoverflow, I am still struggling to grasp the concept of how get('length') functions.
I am attempting to retrieve a user count in the helper model. The issue may lie in my approach to using get('length'), or perhaps I need to utilize RSVP hash to access both the current model and helper model in todo route?
todo.js
export default Ember.Controller.extend({
count: function() {
var helper = this.get('helper');
return helper.user.get('length');
}.property('helper.user.[]'),
todo.js
export default DS.Model.extend({
title: DS.attr('string'),
isCompleted: DS.attr('boolean', {defaultValue: false}),
list: DS.belongsTo('list', {async: true}),
user: DS.belongsTo('user', {async: true}),
comment: DS.hasMany('comment', {async: true}),
helper: DS.hasMany('helper', {async: true}),
});
todo.hbs
<p>
<span class="badge pull-left">14 hands</span>
<span class="badge pull-left">{{todo.count}}</span>
</p>
helper.js
export default DS.Model.extend({
user: DS.belongsTo('user', {async: true}),
todo: DS.belongsTo('todo', {async: true}),
});
todo.js
export default Ember.Route.extend({
model: function(params){
// return model
},