角ng-repeat在其他ng-repeat内?

时间:2022-12-22 21:39:51

I'm trying to create a ng-repeat inside another repeat like this:

我试着在另一个重复的过程中创建一个ng-repeat:

Template:

模板:

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

Json:

Json:

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

    },
"fieldset2"];

the {{fieldset}} get's outputted, like this:

{{fieldset}}得到输出,如下所示:

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

1 个解决方案

#1


2  

It is simple , change it like this:

它很简单,像这样改变:

<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

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

#1


2  

It is simple , change it like this:

它很简单,像这样改变:

<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

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