gpt4 book ai didi

html - Angular 2 - 处理点击禁用输入

转载 作者:太空狗 更新时间:2023-10-29 14:48:37 26 4
gpt4 key购买 nike

这就是我现在所拥有的。正在尝试调用 checkToEnable 函数。

<input type="text" ([ngModel])="city.arr.date" [id]="city.id+'_arr_date'" [name]="city.id+'_arr_date'" [attr.disabled]="selectedTripType=='OT' ? true : null" class="input-icon-date input-default-last  form-control" (click)="checkToEnable()" placeholder="Return Date"/>

最佳答案

Disabled elements don't fire mouse events. Most browsers will propagate an event originating from the disabled element up the DOM tree, so event handlers could be placed on container elements.


但是你可以通过这种方式实现:

组件端:

disableTextbox =  false;

toggleDisable() {
this.disableTextbox = !this.disableTextbox;
}

模板端:

<div (click)='toggleDisable()'>
<input [disabled]='disableTextbox' >
</div>

WORKING DEMO

关于html - Angular 2 - 处理点击禁用输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46902840/

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