角度2->如何使用FormGroup隐藏控件 [英] Angular 2 -> how to hide controls using FormGroup
本文介绍了角度2->如何使用FormGroup隐藏控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使用FormGroup(TypeScript Angular 2)来控制控件的可见性.
Is there any way to control visibility of controls using FormGroup (TypeScript Angular 2).
我要编写以下代码:
this.myDoch.controls['text1'].disable();
但是它只阻止了控件,我正在寻找隐藏控件.
but it only blocked the control, I'm looking for hide the contorl.
谢谢.
推荐答案
您可以像这样使用disabled
:
<input [ngClass]="{'hidden': link.controls.title.disabled}" type="text" formControlName="title" />
component.ts
linkArry.controls[0].disable();
CSS
.hidden {display:none;}
这篇关于角度2->如何使用FormGroup隐藏控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文