Reputation: 727
Basically i am struggling to hide some fields depending on the value of above dropdown selected in a form.
ex: say if i have a category dropdown than for a value of specific category show only specific fields before form submit.
Additionally also i want my categories to come using radio alert but its not showing ??
I tried to make category input a radio type select popup but unable to explore how to do that...
can any one suggest whats the best way.
I am thinking to do with https://ionicframework.com/docs/v2/api/components/alert/AlertController/ .. example of radio alert.
Upvotes: 1
Views: 331
Reputation: 7719
Your radio buttons are probably inside a RadioGroup which has been bound with [(ngModel)]="value"
or something like that.
This way you can hide/show certain fields (I'll demonstrate this with div
s for now) by comparing them to a value.
<div id="onlyOnValue1" *ngIf="value == 'value1'"></div>
<div id="onlyOnValue2" *ngIf="value == 'value2'"></div>
<div id="value3Or4" *ngIf="value == 'value3' || value='value4'"></div>
This will look quite messy if you have a lot of fields to be hidden. So you can extract this into a function if you'd like.
You can also bind to [hidden]
but I myself prefer using Angular's methods instead.
Upvotes: 1