简体   繁体   中英

JS Array findIndex() is not a function

The following code produces always an error:

var index = this.dataSource.findIndex(item => item.id_system === row.id_system);

The error message is: TypeError: this.dataSource.findIndex is not a function

What could be the solution?

If you're using Angular Material example, then you will need to use data array.

Your dataSource should be MatTableDataSource<your type> .

So maybe you can try

let index = this.dataSource.data.findIndex(item => item.id_system === row.id_system);

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