Dynamically loading columns and data in to table in Angular 2

后端 未结 7 893
醉话见心
醉话见心 2020-12-19 09:18

I have an HTML page in which I want to create a table. The columns in this table are dynamic which means that they are fetched from the server into a variable in the compone

7条回答
  •  梦毁少年i
    2020-12-19 09:55

    Here's my solution for Angular 5.x+:

    {{ cols.displayName }}

    Assuming you have columnsData set up like [{displayName: 'First Name', name: 'name'}, {displayName: 'Last Name', name: 'surname'}] Of course, you can customize those however you need.

    You can just interpolate {{ data[col.name] }} instead of using the tag if you don't your fields to be editable.

提交回复
热议问题