admin管理员组文章数量:1418380
I would like to show and hide addtional input fields depending on a radio button value.
Radio
<div class="form-group">
<label>Was möchten Sie bewerten?</label>
<div class="radio">
<label><input type="radio" [(ngModel)]="type" name="type" value="ETW">Eigentumswohnung</label>
</div>
<div class="radio">
<label><input type="radio" [(ngModel)]="type" name="type" value= "EFH">Einfamilienhaus</label>
</div>
<div class="radio">
<label><input type="radio" [(ngModel)]="type" name="type" value="ZFH">Mehrfamilienhaus</label>
</div>
</div
This form/elemnt I would like to show if the value of type is "EFH" or "ZFH"
<div *ngIf="" class="form-group">
I would like to show and hide addtional input fields depending on a radio button value.
Radio
<div class="form-group">
<label>Was möchten Sie bewerten?</label>
<div class="radio">
<label><input type="radio" [(ngModel)]="type" name="type" value="ETW">Eigentumswohnung</label>
</div>
<div class="radio">
<label><input type="radio" [(ngModel)]="type" name="type" value= "EFH">Einfamilienhaus</label>
</div>
<div class="radio">
<label><input type="radio" [(ngModel)]="type" name="type" value="ZFH">Mehrfamilienhaus</label>
</div>
</div
This form/elemnt I would like to show if the value of type is "EFH" or "ZFH"
<div *ngIf="" class="form-group">
Share
Improve this question
asked Mar 17, 2017 at 11:00
Fabian TschullikFabian Tschullik
1554 silver badges10 bronze badges
1 Answer
Reset to default 4As your radio buttons are binded to some property using ngModel, you can use your radio buttons model property to check (show/hide) the div's.
Example :
<div *ngIf="type == 'EFG' || type == 'ZFH'" class="form-group">
本文标签: javascriptShow and hide inputs depending on radio button angular 2Stack Overflow
版权声明:本文标题:javascript - Show and hide inputs depending on radio button angular 2 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745283599a2651570.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论