我正在將 Angular 8 用于我的 Angular-Electron 應用程序。我有一個以表格格式存儲的 API 密鑰字段,該字段非常敏感,需要在用戶的帳戶頁面上向用戶顯示。問題是它需要顯示為密碼文本字段。每當用戶單擊名為“顯示”的按鈕時,API 密鑰可能會顯示幾秒鐘,或者直到用戶再次單擊該按鈕。它不能顯示為輸入字段。這是向用戶顯示用戶帳戶詳細信息的方式:<table _ngcontent-ipg-c7="" class="table"> <thead _ngcontent-ipg-c7="" class=" text-info"> <th _ngcontent-ipg-c7="" style="text-align: center;"> Account Name </th> <th _ngcontent-ipg-c7="" style="text-align: center;"> API Key </th> <th _ngcontent-ipg-c7="" style="text-align: center;"> API Version </th> <th _ngcontent-ipg-c7="" style="text-align: center;"> Imported </th> </thead> <tbody _ngcontent-ipg-c7=""> <tr _ngcontent-ipg-c7="" *ngIf="accountDetails"> <td _ngcontent-ipg-c7="" style="text-align: center;"> {{accountDetails?.accountID}}</td> <td _ngcontent-ipg-c7="" style="text-align: center;"> {{accountDetails?.apiKey}}</td> <td _ngcontent-ipg-c7="" style="text-align: center;"> {{accountDetails?.apiVersion}}</td> <td _ngcontent-ipg-c7="" style="text-align: center;"> {{accountDetails?.is_imported}} </td> </tr> </tbody></table>
1 回答

互換的青春
TA貢獻1797條經驗 獲得超6個贊
最快的解決方案是創建函數并在 html 中編寫函數。
<td _ngcontent-ipg-c7=""(click)="showApi()" style="text-align: center;"> {{getApiPass()}}</td>
isshow=false;
getApiPass(){
if(this.isshow){
return this.accountDetails?.apiKey;
}
return "******";
}
單擊只需更改 isshow 下面的這樣的功能;
showApi(){
this.isshow=!this.isshow;
}
這是示例代碼,您應該用真實的參數名稱更改參數名稱。
- 1 回答
- 0 關注
- 122 瀏覽
添加回答
舉報
0/150
提交
取消