其他ng-repeat中的角度ng重复?

时间:2013-09-12 09:27:25

标签: angularjs

我正在尝试在另一个重复内部创建一个ng-repeat:

模板:

        <fieldset ng-repeat="fieldset in fieldsets">
            {{fieldset}}
            <div class="pair" ng-repeat="field in fields">
                {{field}}
            </div>
        </fieldset>

JSON:

$scope.fieldsets =
[
    {
        fields: [
            'tada',
            'tada'
        ],

    },
"fieldset2"];

{{fieldset}}得到的输出,如下:

<fieldset>
   {"fields":["tada","tada"]}
</fieldset>
<fieldset>
   fieldset2
</fieldset>

1 个答案:

答案 0 :(得分:2)

很简单,就这样改变:

<fieldset ng-repeat="fieldset in fieldsets">
    {{fieldset}}
    <div class="pair" ng-repeat="field in fieldset.fields">
         {{field}}
    </div>
</fieldset>

Plnk:http://plnkr.co/edit/ytBGgP?p=preview