在 *NgFor 中为每一行放置一个按钮

put a button in the *NgFor for each row

我有一个如图所示的网站。我用 *NgFor 创建了列表。我想把最喜欢的按钮放在每一行上。我想通过按收藏按钮将那条线的信息添加到收藏夹

website home page

我的 *ngfor 循环。只是我想要每个“最喜欢的列”的按钮

    <table id="news">
        <tr>
            <th *ngFor="let col of headers">
                {{col}}
            </th>
        </tr>
    
        <tr *ngFor="let new of news">
            <td *ngFor="let col of index">
                {{new[col]}}
            </td>
        </tr>
</table>

创建按钮后,我将连接 mongo 自己

你可以使用这样的东西

<table>
    <tr *ngFor="let new of news>
<td *ngFor="let col of index>
   {{new[col]}}
</td>
<td>
       <button>col.propertyname</button>
    </td>
</table>

谢谢

您应该像这样在 ngFor 中添加按钮:

<table>
  <tr *ngFor="let new of news>
    <td *ngFor="let col of index>
       {{new[col]}}
    </td>
    <td>
       <button>Favorite</button>
    </td>
  </tr>
</table>