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

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

如何獲取所有 Slide-Toggle 元素的 ID 和值

如何獲取所有 Slide-Toggle 元素的 ID 和值

慕妹3242003 2021-10-29 16:22:46
我問了一個(gè)類似的問題。但在這里我的問題有點(diǎn)不同。在表格列中,我有 Slide-Toggle 元素,用戶可以無限時(shí)間將它們?cè)O(shè)為 true 或 false。之后有一個(gè)按鈕,用戶可以提交所有這些真值和假值。在我的 HTML 中,那些 Slide-Toggle 元素來自 for 循環(huán),它是從通知數(shù)組生成的。獲取所有帶有 ID 的滑動(dòng)開關(guān)的值(真、假)的最簡單和最好的方法是什么?正如我提到的,我將提交它們,這就是我想要這樣做的原因。這是我在下面嘗試的HTML<h3>Notifications</h3>    <table class="table" id="thetable">            <thead>              <tr>                <th scope="col">#</th>                <th scope="col">Tasks</th>                <th scope="col">IsFinished</th>              </tr>            </thead>            <tbody>              <tr *ngFor="let not of notifications;"               [ngStyle]="{ 'background-color': (not.isFinished ? '#dddddd' : 'white') }"              >                 <th scope="row">{{not.id+1}}</th>                  <td>{{not.task}}</td>                <td>                        <section class="example-section">                                <mat-slide-toggle                                    [id]="not.id"                                    class="example-margin"                                    [color]="color"                                    [checked]="not.isFinished"                                    [disabled]="not.isFinished"                                    (change)="onChange($event)"                                    >                                </mat-slide-toggle>                              </section>                </td>              </tr>            </tbody>          </table>          <div class="row">                <div class="col">                <button mat-raised-button color="primary" (click)="openDialog()">Add Task</button>                <button mat-raised-button color="primary" (click)="onSave()">Save</button>            </div>TypeScirpt(數(shù)組是怎么來的) ngOnInit() {    this.notifications=this.notificationService.getNotifications();  }
查看完整描述

2 回答

?
飲歌長嘯

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

如果你想獲得變革切換ID的ID,通過not在(change)="onChange(not)"。這是供您參考以跟蹤 id 的更改,您可以在其中為其創(chuàng)建單獨(dú)的數(shù)組


保存時(shí):


onSave(){

  this.finishedNotifications = this.notifications.filter((n) => {

    return n.id && n.isFinished; // filters and returns notifications which are finished only

  })

}


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

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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