简体   繁体   中英

Angular material table dynamic rows

I am creating a project using angular and material. In my project i want to add customised footer row in material table on click of button and delete that row on click of delete button.

Here is my code:

https://stackblitz.com/edit/angular-dshjiz-beqnrj?file=src/app/table-basic-example.html

You need to push data in datasource

this.dataSource.data.push({id: 1, name: 'test'})

There is stackblitz example

You need to push data as mentioned by Armen. You also need to call renderRows() method of the table as per suggestion https://material.angular.io/components/table/overview#1-write-your-mat-table-and-provide-data

Please check your updated stackblitz example

Same method can be implemented to delete the row. Just make sure the renderRows method calls everytime the table updates.

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