简体   繁体   中英

(TS)Property Rows does not exist on type HTMLInputElemet

Hi I am new to angular and type script..I need to check whether table is empty or not and depending upon that I need to hide or display a div. I tried,

var rows = document.getElementById('associatedEmailsTable'))rows; and
var rows =(<HTMLInputElement>document.getElementById('associatedEmailsTable')).rows;

but both are giving same result, Please help me in this.

Please suggest me how can I find whether table tr has any value inside it or not using javascript.

and My HTML code is

   <table class="table table-sm table-hover" id="associatedEmailsTable" style="display:none">
       <tr>
            <th>
              Email
            </th>
            <th>
              Action
            </th>
          </tr>
          <tr *ngFor="let oEmailAddress of this.associatedEmailAddresses">
            <td>{{oEmailAddress.email}}</td>

          </tr>
        </table>

The issue is exactly what the error says, "Property Rows does not exist on type HTMLInputElemet".

Assuming that you have <table id="associatedEmailsTable">... then what you have is a HTMLTableElement . So:

var rows = (document.getElementById('associatedEmailsTable') as HTMLTableElement).rows;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM