I have variable called tableIndexNumber that i need use inside diffrent methodts. So when i try to reach that variable i use "this.tableIndexNumber" and i can reach it. But i cant use it this way inside Jquery each loop because of htmlElemets define as "this" too inside the each loop. So which way should i follow ?
export class TablesComponent implements OnInit {
tableIndexNumber = 1;
constructor() { }
change(col: number) {
$('#' + col).each(function () {
if ($(this).attr('class') === 'box') {
$(this).addClass('boxSelected');
this.tableIndexNumber ++;
} else {
$(this).removeClass('boxSelected').addClass('box');
}
});
}