I have a hbs that displays a table for the list of data that is fed to the component
templates/components/results.hbs
<tbody>
{{#each resultsDetail as |resultDetail|}}
<tr>
<td>
{{resultDetail.samples}}
</td>
<td class=" {{if isFailure "alert-danger" "alert-success"}}"{{/if}} >
{{resultDetail.failures}}
</td>
{{/each}}
</tbody>
the corresponding js file is components/results.js
export default Ember.Component.extend({
isFailure: false,
didInsertElement: function () {
this.calculateFailure();
},
calculateFailure: function () {
var resultDetails = this.get('resultsDetails');
for (var resultDetail in resultDetails) {
if (resultDetail.failures == 0) this.set('isFailure', true);
}
}.observes('resultsDetails'),
});
I know what I am doing is wrong.
What I want is for the resultsDetails list, if the failure value is set to 0, i want the flag to be false, so in my handle bar, if the data is a failure my td class is set to alert-danger.
I am totally new to ember so most of the google and ember guides were too complex to understand. Could anyone guide me to the right direction?
Thank you in advance.