I am using Angular 2 Typescript. I am facing a problem wherein I need to submit a form which contains check boxes. I need values that are in the attributes of checkboxes. The ch
I use this for the checkboxes: ng2-material checkbox
And you could do this in your component:
selected = [];
@Output() selectedChange:EventEmitter = new EventEmitter();
toggle(id) {
var index = this.selected.indexOf(id);
if (index === -1) this.selected.push(id);
else this.selected.splice(index, 1);
this.selectedChange.emit(this.selected);
}
exists(id) {
return this.selected.indexOf(id) > -1;
}