gpt4 book ai didi

html - 除非选中复选框(Angular 7+),否则禁用按钮?

转载 作者:太空宇宙 更新时间:2023-11-04 00:36:00 25 4
gpt4 key购买 nike

除非选中所有复选框,否则我想禁用按钮?你如何在 Angular 中实现这个?

这是不同的,因为它不是一种形式,而且这个问题还没有得到回答,因为没有 for 循环。

    <div class="md-input-group md-checkbox md-input--nested-1">
<input type="checkbox" class="md-input md-checkbox__input" id="checkboxNested1" name="checkboxNested1">
<label style="margin-left: -30px;" class="md-checkbox__label" for="checkboxNested1">
<p>Checkbox 1</p>
</label>
</div>

<div class="md-input-group md-checkbox md-input--nested-1">
<input type="checkbox" class="md-input md-checkbox__input" id="checkboxNested1" name="checkboxNested1">
<label style="margin-left: -30px;" class="md-checkbox__label" for="checkboxNested1">
<p>Checkbox 2</p>
</label>
</div>

<button class="md-button" md-button color="red" aria-label="delete">Delete organization</button>


最佳答案

例如:Angular 2 Checkbox Two Way Data Binding .

export class FooComponenet {
checkbox1 = false; // bind first checkbox
checkbox2 = false; // another checkbox
}
<!-- or use (change)="methodName()" -->
<input type="checkbox" [checked]="checkbox1" (change)="checkbox1 = !checkbox1"/>
<input type="checkbox" [checked]="checkbox2" (change)="checkbox2 = !checkbox2"/>

<button [disabled]="!checkbox1 || !checkbox2">Bar</button>

<!-- or this -->
<button [attr.disabled]="!checkbox1 || !checkbox2">Bar</button>

你也可以使用:

关于html - 除非选中复选框(Angular 7+),否则禁用按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59399089/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com