Reputation: 1006
Here's my question:
I have a list of books, with the isAvailable
boolean property
I would like to create a property called availability
, which will return "product available" if isAvailable
, and I'd like to use this property in an #each
statement
availability: function () {
if (this.get('isAvailable'))
return "book available";
else
return "book not available";
}.property()
{{#each book in arrangedContent}}
{{availability}}
{{/each}}
In which object must I define my new property?
Upvotes: 0
Views: 35
Reputation: 663
Extend your books model:
var model;
model = DS.Model.extend({
isAvailable: DS.attr('boolean'), // This is what you already have
availability: function() {
if (this.get('isAvailable')) {
return 'book available';
} else {
return 'book not available';
}
}.property('isAvailable')
});
export default model;
In your template you have to write book.availability...
Upvotes: 1