无法从动态表单中获取所选下拉菜单的值

我正在基于以下json创建动态表单:

[
    {
        "type": "text","name": "First Name","value": "","placeholder":"First Name","required": true
    },{
        "type": "text","name": "Last Name","placeholder":"Last Name",{
        "type": "select","name": "Country","placeholder":"","required": true,"options": [
            {
                "name": "LL","code": "LL"
            }
        ]
    }
]

我在文本字段的最终json中获取了值,但没有在所选下拉列表中获取值:

无法从动态表单中获取所选下拉菜单的值

这是控制台中上述输入的相应json,我正在获取:

无法从动态表单中获取所选下拉菜单的值

如您所见,国家/地区

这就是我的 app.component.html 的样子

<div *ngIf="low">
        <div>
            <form #form="ngForm">
                <div *ngFor="let input of lowPassData">
                    <div *ngIf="input.type == 'text'">
                        <label [for]='input.name'>{{input.name}}</label>
                        <input [type]='input.type'
                        [name]='input.name'
                        [(ngModel)]='input.value'
                        [placeholder]='input.value'
                        [required]='input.required'
                        class="box"
                        />
                    </div>
                    <div *ngIf="input.type == 'select'">
                        <label [for]='input.name'>{{input.name}}</label>
                        <select
                            [(ngModel)]='input.value'
                            [required]='input.required'
                            >
                            <option *ngFor="let country of input.options" >{{country.name}}</option>
                        </select>
                    </div>
                </div>
            </form>
            <button pButton type="button" label="Click" (click)="addInputs()" [disabled]="!form.valid"></button>
        </div>

这是我的 .ts 文件

 lowPass(){
    this.lowPassData= adData;
    this.low= true;
  }

此处 adData 指问题的第一个json文件。

谁能建议我该怎么做

lytdydy 回答:无法从动态表单中获取所选下拉菜单的值

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3089047.html

大家都在问