ng-repeat multiple $ index

0

I have the following code:

     var personas = { 
       { persona1: { hijos: [1,2,3]}}, 
       { persona2: { hijos: [2,2,3]}}, 
       { persona1: { hijos: [1,2,3]}} 
    }

    <div>
        <div ng-repeat="(key, hijos) in personas">
        <label class="" style="width: 300px">{{key}}</label>

        <div ng-repeat="hij in hijos track by $index">
            <label style="width: 110px;">{{hij | number:2}}</label>
        </div>
    </div>

But in console I'm getting [ngRepeat: dupes], the problem is that in the first one there is some repeated and I have to put each ng-repeat an $ index, but you can not

    
asked by sirdaiz 03.12.2018 в 11:38
source

1 answer

0

To your object you have about {} , it should be like this:

var personas = { 
   persona1: { hijos: [1,2,3]}, 
   persona2: { hijos: [2,2,3]}, 
   persona1: { hijos: [1,2,3]} 
};

And the marking would be more like this:

<div>
    <div ng-repeat="(key, persona) in personas">
    <label style="width: 300px">{{ key }}</label>

    <div ng-repeat="hijo in persona.hijos">
        <label style="width: 110px;">{{ hijo | number:2 }}</label>
    </div>
</div> 
    
answered by 06.12.2018 в 16:55