【发布时间】:2020-08-14 10:17:48
【问题描述】:
您好,我正在使用 angularjs 构建一个表单,我有一个这样的 php 返回的数组,我想从该数组构建一个这样的表单。
<b>Company</b>
<select ng-model="attributs[]">
<option>Chinese</option>
<option>Japanese</option>
</select>
<b>Color</b>
<select ng-model="attributs[]">
<option>Black</option>
<option>Red</option>
</select>
[
{
id: 1,
name: "Company",
attribute_values:[
{
id: 1,
name: "Chinese"
},
{
id: 2,
name: "Japanese"
}
]
},
{
id: 2,
name: "Color",
attribute_values:[
{
id: 4,
name: "Black"
},
{
id: 5,
name: "Red"
}
]
}
]
我想要从选择选项中选择的所有值,我尝试了这个但没有工作。提前谢谢你。
<div ng-repeat="attrib in attributes.data">
<label class="col-sm-5 col-form-label"><% attrib.name %></label>
<div class="col-sm-5">
<select ng-model="attrib.attributeSelected" ng-options="atb.value as atb.name for atb in attrib.attribute_values">
</select>
</div>
</div>
【问题讨论】: