最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Error while building an angular project for Tuple type '[]' of length '0' has no el

programmeradmin10浏览0评论

Following is the error when I am executing the following prod mand

ng build --prod

ERROR in src/app/inventory/inv-parts-main-table/dialog-ponent/dialog-ponentponent.html(5,16): Tuple type '[]' of length '0' has no element at index '0'.

src/app/inventory/inv-parts-main-table/dialog-ponent/dialog-ponentponent.html(5,62): Tuple type '[]' of length '0' has no element at index '0'.

src/app/inventory/inv-parts-main-table/dialog-ponent/dialog-ponentponent.html(5,62): Tuple type '[]' of length '0' has no element at index '0'.

src/app/inventory/inv-parts-main-table/dialog-ponent/dialog-ponentponent.html(9,16): Tuple type '[]' of length '0' has no element at index '1'.

src/app/inventory/inv-parts-main-table/dialog-ponent/dialog-ponentponent.html(9,62): Tuple type '[]' of length '0' has no element at index '1'.

src/app/inventory/inv-parts-main-table/dialog-ponent/dialog-ponentponent.html(9,62): Tuple type '[]' of length '0' has no element at index '1'.

src/app/inventory/inv-parts-main-table/dialog-ponent/dialog-ponentponent.html(13,16): Tuple type '[]' of length '0' has no element at index '2'.

src/app/inventory/inv-parts-main-table/dialog-ponent/dialog-ponentponent.html(13,62): Tuple type '[]' of length '0' has no element at index '2'.

src/app/inventory/inv-parts-main-table/dialog-ponent/dialog-ponentponent.html(13,62): Tuple type '[]' of length '0' has no element at index '2'.

Source code related to the above error looks like this

<div mat-dialog-content>
    <div style="margin-top: 30pt" *ngIf="data.quote[0]!=null">
      <span><b>{{data.quote[0] | currency}}</b></span> <br />
      {{data.lastUpdatedDate[0] | date :'mediumDate'}} | {{data.supplierName[0]}}
    </div>
    <div style="margin-top: 10pt" *ngIf="data.quote[1]!=null">
      <span><b>{{data.quote[1] | currency}}</b></span> <br />
      {{data.lastUpdatedDate[1] | date :'mediumDate'}} | {{data.supplierName[1]}}
    </div>
    <div style="margin-top: 10pt" *ngIf="data.quote[2]!=null">
      <span><b>{{data.quote[2] | currency}}</b></span> <br />
      {{data.lastUpdatedDate[2] | date :'mediumDate'}} | {{data.supplierName[2]}}
    </div>
</div>

The Ts file looks like below

export interface DialogData {
  quote: [];
  lastUpdatedDate : [];
  supplierName: [];
}

Following is the error when I am executing the following prod mand

ng build --prod

ERROR in src/app/inventory/inv-parts-main-table/dialog-ponent/dialog-ponent.ponent.html(5,16): Tuple type '[]' of length '0' has no element at index '0'.

src/app/inventory/inv-parts-main-table/dialog-ponent/dialog-ponent.ponent.html(5,62): Tuple type '[]' of length '0' has no element at index '0'.

src/app/inventory/inv-parts-main-table/dialog-ponent/dialog-ponent.ponent.html(5,62): Tuple type '[]' of length '0' has no element at index '0'.

src/app/inventory/inv-parts-main-table/dialog-ponent/dialog-ponent.ponent.html(9,16): Tuple type '[]' of length '0' has no element at index '1'.

src/app/inventory/inv-parts-main-table/dialog-ponent/dialog-ponent.ponent.html(9,62): Tuple type '[]' of length '0' has no element at index '1'.

src/app/inventory/inv-parts-main-table/dialog-ponent/dialog-ponent.ponent.html(9,62): Tuple type '[]' of length '0' has no element at index '1'.

src/app/inventory/inv-parts-main-table/dialog-ponent/dialog-ponent.ponent.html(13,16): Tuple type '[]' of length '0' has no element at index '2'.

src/app/inventory/inv-parts-main-table/dialog-ponent/dialog-ponent.ponent.html(13,62): Tuple type '[]' of length '0' has no element at index '2'.

src/app/inventory/inv-parts-main-table/dialog-ponent/dialog-ponent.ponent.html(13,62): Tuple type '[]' of length '0' has no element at index '2'.

Source code related to the above error looks like this

<div mat-dialog-content>
    <div style="margin-top: 30pt" *ngIf="data.quote[0]!=null">
      <span><b>{{data.quote[0] | currency}}</b></span> <br />
      {{data.lastUpdatedDate[0] | date :'mediumDate'}} | {{data.supplierName[0]}}
    </div>
    <div style="margin-top: 10pt" *ngIf="data.quote[1]!=null">
      <span><b>{{data.quote[1] | currency}}</b></span> <br />
      {{data.lastUpdatedDate[1] | date :'mediumDate'}} | {{data.supplierName[1]}}
    </div>
    <div style="margin-top: 10pt" *ngIf="data.quote[2]!=null">
      <span><b>{{data.quote[2] | currency}}</b></span> <br />
      {{data.lastUpdatedDate[2] | date :'mediumDate'}} | {{data.supplierName[2]}}
    </div>
</div>

The Ts file looks like below

export interface DialogData {
  quote: [];
  lastUpdatedDate : [];
  supplierName: [];
}
Share Improve this question edited Mar 16, 2021 at 17:30 gmhk asked Mar 16, 2021 at 16:31 gmhkgmhk 16k29 gold badges91 silver badges112 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 18

Following ts change helped me to fix this issue

Tuple type '[]' of length '0' has no element at index '1'.

export interface DialogData {
  quote: string[];
  lastUpdatedDate : string[];
  supplierName: string[];
}

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论