Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2 -> how to hide controls using FormGroup

Is there any way to control visibility of controls using FormGroup (TypeScript Angular 2).

I'm manage to write the following code:

this.myDoch.controls['text1'].disable();

but it only blocked the control, I'm looking for hide the contorl.

Thanks.

like image 447
haya Avatar asked Mar 26 '17 05:03

haya


2 Answers

You can use disabled like this:

HTML

<input [ngClass]="{'hidden': link.controls.title.disabled}" type="text" formControlName="title" />

component.ts

linkArry.controls[0].disable();

CSS

.hidden {display:none;}

like image 102
KarateJB Avatar answered Sep 30 '22 07:09

KarateJB


You can use the 'disabled' css selector. For example :

.my-input:disabled {
    display:none;
}

You can read about it here.

like image 25
Gili Yaniv Avatar answered Sep 30 '22 08:09

Gili Yaniv