根据条件禁用按钮

时间:2020-09-19 08:03:32

标签: html angular html-table angular10

我正在从服务器获取数据,并且想过滤出特定的列。我想要的是,如果所购买的列(布尔值)为true,则必须禁用编辑按钮,如果其为false,则必须显示编辑内容

在此处输入代码

            <div *ngIf="isbaker">
    <div class="table-responsive">
        <table class="table">
            <thead class="table_header">
                <tr>
                    
                    <th>Customer</th>
                    <th>Name</th>
                    <th>Bought</th>
     
                </tr>
            </thead>
            <tbody>
                <tr *ngFor="let baker of shop;">            
                    <td>{{  baker.customer }}</td>
                    <td>{{ baker.name}}</td>
                    <td>{{  baker.bought}}</td>
               
                    

                    <td  *ngIf="isButton">
                        <button mat-icon-button matTooltip=" Edit" class="iconbutton" (click)="isbakerEdit(baker)"
                            color="primary">
                            <mat-icon style="color: gray;" aria-label="Edit">edit</mat-icon>
                        </button>
                    </td>  
                </tr>
            </tbody> 
        </table>`

2 个答案:

答案 0 :(得分:2)

您可以使用Angular提供的Disabled指令。

# cost/loss function
cost = tf.reduce_mean(tf.square(hypothesis - Y))

# cost/loss function
cost = tf.reduce_sum(tf.square(hypothesis - Y))

答案 1 :(得分:1)

   <button mat-icon-button matTooltip=" Edit" class="iconbutton"(click)="isbakerEdit(baker)" 
       color="primary" [disabled]="baker?.bought">
       <mat-icon style="color: gray;" aria-label="Edit">edit</mat-icon>
   </button>

您要做的就是将其称为[disabled]="baker?.bought