根据下拉文本框中的选择值,将在Angular中启用或禁用
我根据我编写代码,以一个下拉列表,由2个值IE启用,禁用。根据选择,应启用和禁用文本框。有人可以告诉我如何
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-dropdown',
templateUrl: './dropdown.component.html',
styleUrls: ['./dropdown.component.css']
})
export class DropdownComponent implements OnInit {
des = false
constructor() { }
onchange(){
if (true) {
this.des=false
}
else{
this.des= true
}
}
ngOnInit(): void {
}
}
<select name="dropdown" id="this">select the correct value
(change)="onchange()"
<option value="yes">yes</option>
<option value="No">No</option>
</select>
<input type="text" [disabled]="!des">
采取选项的价值以及我可以在IF-ELSE部分中提供的条件
I write the code according to me for one dropdown consisting of 2 values i.e. Enabled, Disabled. As per the selection, the textbox should be enabled and disabled. can anybody tell me how to
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-dropdown',
templateUrl: './dropdown.component.html',
styleUrls: ['./dropdown.component.css']
})
export class DropdownComponent implements OnInit {
des = false
constructor() { }
onchange(){
if (true) {
this.des=false
}
else{
this.des= true
}
}
ngOnInit(): void {
}
}
<select name="dropdown" id="this">select the correct value
(change)="onchange()"
<option value="yes">yes</option>
<option value="No">No</option>
</select>
<input type="text" [disabled]="!des">
take the value of options and what condition I can give in the if-else section
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在html文件
中
In HTML file add event as a parameter in your case:
and in ts file add function