简体   繁体   English

angular chekcbox 被选中更改其他输入值

[英]angular chekcbox is checked change other input value

I want to find a solution that if I check a checkbox then the value of the input field in another div will change to disabled.我想找到一个解决方案,如果我选中一个复选框,那么另一个 div 中输入字段的值将更改为禁用。

`` ``

<div class="24hr-example">
        <input placeholder="24hr format" aria-label="24hr format" [ngxTimepicker]="fullTime" [format]="24"  readonly>
        <ngx-material-timepicker #fullTime></ngx-material-timepicker>
   </div>

`` ``

<app-checkbox [checked]="openingHours.is_closed_all_day" (change)="openingHours.is_closed_all_day = !openingHours.is_closed_all_day"></app-checkbox>

So if I click on the checkbox then the value of the input field given will be taken as disabled.因此,如果我单击复选框,则给定的输入字段的值将被视为禁用。 I've tried to solve it with a function, but it couldn't work.我试图用一个函数来解决它,但它不起作用。 What solution is possible to solve this?什么解决方案可以解决这个问题?

<input type="checkbox" [(ngModel)]="isChecked" (change)="checkValue(isChecked)" />

inside your class:在你的班级里:

checkValue(event: any){
   console.log(event);

if(any){
// disable value
}else{
//enable value
}
}

Hope you get the logic.希望你明白逻辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM