Trying to add classname and set some style for td of each tr in the table using typescript. I have tried, But it is not working. If anyone knows please help to find the solution.
app.component.ts:
ngOnInit() {
this.elRef.nativeElement
.querySelectorAll('#contect table tbody tr')
.forEach((element, index, array) => {
console.log(element);
element.forEach((element, index, array) => {
if (index == 0) {//first td of tr
element.classList.add('bg');
element.style.right = '2px';
}
});
});
}
}