I am creating an array of pills and would like to add a data-* attribute to each item. But unfortunately I get a syntax error.
I tried changing the field name 'data-id' to 'dataId' but still wasn't able to query the field using event.target.dataset.dataId
.
What is the right syntax for this?
import { LightningElement, track } from 'lwc';
export default class App extends LightningElement {
@track items = [
];
handleClick(event){
let obj ={
label: 'test',
data-Id: 'my data id' <---- This is where I get syntax error
}
this.items.splice(this.items.length,0,obj) //adding new items to array
}
copyPillToForm(event){
console.dir(event.target.dataset.data-Id)
}
}
{}
button.