首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >BS4表问题

BS4表问题
EN

Stack Overflow用户
提问于 2021-09-15 21:44:12
回答 1查看 18关注 0票数 0

您好,我已经尝试做一个表,有费用,金额凯行动,但我有一个问题的对齐。我试图通过宽度纠正它,但不幸的是它不起作用。我做错了什么?

代码语言:javascript
复制
<head>
        <meta charset="ISO-8859-1">
        <link rel="stylesheet" 
            href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" 
            integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" 
            crossorigin="anonymous">
        </head>
        
    <body>
    <a routerLink="/addexpense">Add Expense</a>
    
    <div class="div1">
    <label for="keyword">Search:</label>
    <input type="text" 
    id="keyword"
    [(ngModel)]="filters.keyword"
    name="keyword"
    (input)="listExpenses()">
    </div>
    <div class = "container">
      
    <table class = "table table-striped table-bordered" >
       <tr>
         <th>Expense</th>
         <th>Amount</th>
         <th>Actions</th>
       </tr>
         
         
         
       <div *ngFor ="let expense of expenses">
        <tr> 
         <td>{{expense.expense}}</td>
         <td>{{expense.amount | currency: '&euro;'}}</td>
         <td> <a routerLink ="/editexpense/{{expense.id}}">Edit</a>
              <button *ngIf="expense.id" (click)="deleteExpense(expense.id!)">Delete</button>
         </td>  
        </tr>
       </div>
      </table>
     </div>
    </body>

结果:

EN

回答 1

Stack Overflow用户

发布于 2021-09-16 01:16:19

不将*ngFor绑定到<div>元素。

相反,您需要将*ngFor <tr> 绑定到 element,并从< <div> >D21>中删除element<代码>E220。

代码语言:javascript
复制
<table class="table table-striped table-bordered">
  <tr>
    <th>Expense</th>
    <th>Amount</th>
    <th>Actions</th>
  </tr>

  <tr *ngFor="let expense of expenses">
    <td>{{expense.expense}}</td>
    <td>{{expense.amount | currency: '&euro;'}}</td>
    <td> <a routerLink="/editexpense/{{expense.id}}">Edit</a>
      <button *ngIf="expense.id" (click)="deleteExpense(expense.id!)">Delete</button>
    </td>
  </tr>
</table>

Sample Solution on StackBlitz

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69200115

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档