Here is a checkbox that I am populating with different days of the week:
ts
daysofWeek = [
{ id: 0, name: 'Sunday' },
{ id: 1, name: 'Monday' },
{ id: 2, name: 'Tuesday' },
];
days = [];
html
<div repeat.for="day of daysofWeek">
<md-checkbox checked.bind="days" model.bind="day">${day.name}</md-checkbox>
<ul>
<li repeat.for="day of days">${day.id}</li>
</ul>
</div>
In my TypeScript code, I am trying to retrieve the ID of the checked days. However, it's returning:
0:{id:0,name:sunday}
1:{id:1,name:monday}
submit() {
let daysofweek = this.days; // returns: 0:{id:0,name:sunday}1:{id:1,name:monday}
if (this.repeat === true) {
this.Instance({
daysOfWeek: daysofweek, //how do i pass in here [0,1]
});}
I attempted to modify the HTML like this:
<md-checkbox checked.bind="days" model.bind="day.id">${day.name}</md-checkbox>
but unfortunately, it did not work.
I also tried in TypeScript:
let daysofweek = this.days.id;
However, I encountered an error stating that it couldn't find the property "id."