gpt4 book ai didi

javascript - 选择标签未以正确的形式返回输入数据( Angular )

转载 作者:行者123 更新时间:2023-12-03 07:05:16 24 4
gpt4 key购买 nike

使用我的 json 文件,我在我的网络应用程序上提出选择类型的问题。我的选择标签的代码如下:

<div class="form-group" ng-class="{ 'has-error': form.$submitted && form[field.id].$invalid }" ng-if="field.type === 'select'">
<label for="{{field.id}}">{{field.title}}</label>
<br>
<select ng-model="formData[field.id]" ng-value="{{value.title.id}}" ng-options="value as value.title for value in field.values">
<option disabled selected value> -- select an option -- </option></select>
<p class="form-group-note" ng-if="field.info" ng-bind="field.info"></p>
<div ng-show="form.$submitted" ng-cloack>
<span class="help-block" ng-show="form['{{field.id}}'].$error.required" ng-if="field.validations.required">Please enter a value, this field is required</span>
</div>
</div>

我有一个如下所示的 json 文件:

{
"groups": [
{
"id": "10_8_group",
"title": "Existence",
"index": 60,
"part": 10,
"sections": [
{
"id": "10_8_section",
"title": "Existence",
"fields": [
{
"id": "10_8_labor_organization",
"title": "8. Does it exist?",
"info": "Always select \"No\"",
"type": "select",
"size": {
"width": 100,
"height": 1
},
"values": [
{
"id": 1,
"title": "Yes"
},
{
"id": 2,
"title": "No. If no, proceed to Part 9. and type or print your explanation."
}
]
}
]
}
]
}
]
}

当数据保存在localStorage(Angular的前端模型)中时,它将数据保存为"10_8_labor_organization":{"id":1,"title":"Yes"}}

但是,我想将其另存为

"10_8_labor_organization":"Yes"

我怎样才能做到这一点?

最佳答案

编写代码,例如value.id as value.title for value in field.values

关于javascript - 选择标签未以正确的形式返回输入数据( Angular ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36851162/

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