I have an empty array with lit-element to add the ages between 2 to 13 years that I generate with a loop. I need to add each element within the array using a method but I don't know how to make it work. This is what I have:
import { LitElement, html } from 'lit-element';
class ChildrenInput extends LitElement {
static get properties() {
return {
ages: {type: Array},
};
}
constructor() {
super();
this.minAge = 2;
this.maxAge = 13;
this.ages = [];
}
ages() {
for (let age = this.minAge; age <= this.maxAge; age++) {
this.ages.push(age);
}
}
render(){
return html`
<div>
<select>
<option selected>--</option>
<option>${this.ages.map(item => html`<li>${item}</li>`)}</option>
</select>
</div>
`;
}
}
customElements.define('children-input', ChildrenInput);