gpt4 book ai didi

javascript - ngIf Angular react 形式组件值

转载 作者:行者123 更新时间:2023-11-30 09:11:07 24 4
gpt4 key购买 nike

我有一组单选按钮。如果用户选择值"is",我想在表单上显示一个额外的框。

https://stackblitz.com/edit/angular-4bgahw?file=src/app/personal/personal.component.ts

HTML.component

<div formGroupName="radioButtonsGroup" class="form-group col-6 pl-0 pt-3">

<div class="form-check-inline" *ngFor="let item of personal.radioButtonsdata">
<label for="{{item.section}}" class="col-12 customradio"
><span>{{item.section}}</span>
<input [value]="item" id="{{item.section}}" type="radio" formControlName="selectedButton"/>
<span class="checkmark"></span>
</label>
</div>

<!-- <div class="col-md-8" *ngIf="selectedButton.control.item === 'yes'"> --> //my attempt to target above input value
<div class="col-md-8" >
<input type="text" formControlName="title" class="form-control" placeholder="Title">
</div>
</div>

任何人都可以让它工作并告诉我我在这里做错了什么吗?

最佳答案

您需要访问表单控件的值:

*ngIf="form.get('radioButtonsGroup.selectedButton').value.section === 'yes'">

STACKBLITZ

关于javascript - ngIf Angular react 形式组件值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58877901/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com