【发布时间】:2023-03-11 05:08:01
【问题描述】:
我有一个搜索栏和复选框:
<input type="text" placeholder="Search..." (keyup)="onKey()" [(ngModel)]="input">
<input type="checkbox" (click)="clearSearch()" [(ngModel)]="checkbox">View All
每当有人在搜索栏中键入内容时,我都希望复选框处于未选中状态。 同样,每当有人选中复选框时,我都希望清除搜索栏。
我尝试了以下方法:
export class App {
checkbox = ['checked']
clearSearch() {
this.input = '';
};
onKey() {
checkbox = ['unchecked']
}
但这显然不太奏效。
这是一个带有上述代码的 plunker:https://plnkr.co/edit/uAYxswpoz18jlRUqAMn5?p=preview
实现此功能的最佳方法是什么?
谢谢!
【问题讨论】:
标签: html css angular checkbox input