第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

ngIf 中的條件如何僅對(duì)所選行為真

ngIf 中的條件如何僅對(duì)所選行為真

UYOU 2021-06-28 00:20:23
我正在使用 Angular 版本 7 開發(fā)一個(gè) angular 項(xiàng)目。我有一個(gè)顯示一些 json 對(duì)象的表。在每個(gè) json 對(duì)象中,我添加了 2 個(gè)按鈕,當(dāng)每個(gè)按鈕被選中時(shí),我都會(huì)有條件地顯示這些按鈕。我的意思是,當(dāng)我單擊“編輯”按鈕時(shí),我希望僅在我按下按鈕的那一行顯示“無(wú)編輯”按鈕,反之亦然。但是發(fā)生的情況是,當(dāng)我單擊特定行的“編輯”按鈕時(shí),其他行的所有其他按鈕都會(huì)更改。我怎樣才能做到這一點(diǎn)?myapp.component.html文件:<table>    <thead>      <tr>        <th scope="col" translate>Name</th>        <th scope="col" translate>Description</th>      </tr>    </thead>    <tbody>      <tr *ngFor=" let product of products">        <td>{{product.name}}</td>        <td>{{datasource.description}}</td>        <td>          <button *ngIf="allowEdit" (click)="edit(product)">            Edit          </button>&nbsp;          <button *ngIf="allowNoEdit" (click)="noEdit(product)">            No Edit          </button>&nbsp;        </td>      </tr>    </tbody>  </table>myapp.component.ts文件:allowEdit: boolean = true;allowNoEdit: boolean = false;edit(product) {   this.allowEdit= !this.allowEdit;   this.allowNoEdit= !this.allowNoEdit;}noEdit(product) {   this.allowEdit= !this.allowEdit;   this.allowNoEdit= !this.allowNoEdit;}
查看完整描述

3 回答

?
慕田峪4524236

TA貢獻(xiàn)1875條經(jīng)驗(yàn) 獲得超5個(gè)贊

包含將此類按鈕顯示為 json 對(duì)象的一部分的條件怎么樣?單擊編輯時(shí),您可以修改特定 json 對(duì)象(行)的標(biāo)志并顯示您需要的任何內(nèi)容

為每個(gè)產(chǎn)品初始化 a product.allowEdit = false。然后你的Edit按鈕會(huì)調(diào)用一個(gè)allowEdit(product)()函數(shù),你可以在其中更改標(biāo)志product.allowEdit = !product.allowEdit;


查看完整回答
反對(duì) 回復(fù) 2021-07-01
  • 3 回答
  • 0 關(guān)注
  • 143 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)