import Ember from "ember";
export default Ember.Controller.extend({
trucks: [
{ name: "truck 1", inUse: false },
{ name: "truck 2", inUse: true },
],
actions: {
changeTruck(truck, inUse) {
Ember.set(truck, "inUse", inUse);
},
},
});
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'input',
attributeBindings: ['checked', 'type'],
type: 'checkbox',
change() {
if (this.attrs['on-change']) {
let checked = this.$().is(':checked');
this.attrs['on-change'](checked);
}
}
});
{{#each trucks as |truck|}}
<table>
<tbody>
<tr>
<td>{{truck.name}}</td>
<td>
{{ddau-checkbox checked=truck.inUse on-change=(action 'changeTruck' truck)}}
</td>
</tr>
</tbody>
</table>
{{/each}}