简体   繁体   English

根据单选按钮角度2显示和隐藏输入

[英]Show and hide inputs depending on radio button angular 2

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" 我想显示此表格/元素类型的值是“ EFH”还是“ ZFH”

  <div *ngIf="" class="form-group">

As 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. 使用ngModel将单选按钮绑定到某些属性后,您可以使用单选按钮模型属性检查(显示/隐藏)div的属性。

Example : 范例:

  <div *ngIf="type == 'EFG' || type == 'ZFH'" class="form-group">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM