我正试图在另一个角度重复内部进行角度重复。如果我写:
{{field.labels}} 它输出如下数组:
[{"name":"media","label":"Media"},{"name":"frilans","label":"Frilans"}]
如果我尝试一些非常简单的事情,比如
<fieldset
class="options"
ng-repeat="mylabel in field.labels"
>
<input type="radio" >{{mylabel}}
</fieldset>
它似乎正在工作,因为输入标签的数量对应于数组中的项目数,但它不会输出{{mylabel}}。为什么呢?
以下是代码的完整示例: http://codepen.io/anon/pen/FEyir
以下是完整的字段变量,.options
仅在type = radio时使用:ng-switch-when="radio"
fields:
[
{
label: 'First Name',
name: 'firstname',
key: '',
type: 'text',
//fixa requierd i templatesen
required: true
},
{
label: 'Last Name',
name: 'lastname',
key: '',
required: true,
},
{
label: 'Email',
name: 'email',
key: '',
required: true,
type: 'email',
},
{
key: '',
type: 'radio',
labels:
[
{
name: 'media',
label: 'Media'
},
{
name: 'frilans',
label: 'Frilans'
}
],
}
],
},
答案 0 :(得分:1)
<fieldset
class="options"
ng-repeat="mylabel in field.labels">
<input type="radio" >{{mylabel}}
</fieldset>
替换为:
<!--radiobuttons-->
<fieldset ng-switch-when="radio" class="options">
<span ng-repeat="mylabel in field.labels">
<input type="radio" > {{mylabel.label}}
</span>
</fieldset>