l-lin / angular-datatables

DataTables with Angular
https://l-lin.github.io/angular-datatables/
MIT License
1.57k stars 486 forks source link

Element implicitly has an 'any' type because expression of type '"value"' can't be used to index type 'HTMLElement'. #1625

Closed glolut closed 2 years ago

glolut commented 2 years ago

:beetle: bug report

A clear and concise description of what the bug is.

:microscope: Minimal Reproduction

StackBlitz/GitHub Link:

Step-by-step Instructions:

:8ball: Expected behavior

A clear and concise description of what you expected to happen.

:camera: Screenshots

:globe_with_meridians: Your Environment

:memo: Additional context

I copied "Individual column searching" example from "https://l-lin.github.io/angular-datatables/#/advanced/individual-column-filtering" but it seems like there is an error at this['value']. It give me an error as : Element implicitly has an 'any' type because expression of type '"value"' can't be used to index type 'HTMLElement'. Property 'value' does not exist on type 'HTMLElement'.ts(7053)

  ngAfterViewInit(): void {
    this.datatableElement.dtInstance.then((dtInstance: DataTables.Api) => {
      dtInstance.columns().every(function () {
        const that = this;
        $('input', this.footer()).on('keyup change', function () {
          if (that.search() !== this['value']) {              //error here
            that
              .search(this['value'])                                //and here
              .draw();
          }
        });
      });
    });
  }

Can anyone give me a solution?

glolut commented 2 years ago

I found the solution at: https://stackoverflow.com/questions/12989741/the-property-value-does-not-exist-on-value-of-type-htmlelement Just replace: this['value'] With: (<HTMLInputElement>this).value

NitishOritro commented 1 year ago

Saved My day