0

I have a ng-repeat iteration like this:

<p ng-repeat="(label,field) in app.config.properties">
                <span class="radio-group" > 
                        <div ng-repeat="option in x.options">
                              {{label}}
                        </div>
                    </span>

</p>

I am unable to access the label inside nested loop. I also tried using $parent.label but doesn't seem to work.

beNerd
  • 3,314
  • 6
  • 54
  • 92

1 Answers1

3

It seems to be an issue about <p> and ng-repeat(<p> doesn't show), when I changed <p> to <div>, it's working well.

UPD:

You can move inside ng-repeat to <span> and remove the <div> in it, this way will work with <p>, this is also commented by @ Karan Desai.

angular.module("app", [])
  .controller("myCtrl", function($scope) {
    $scope.app = {
      config: {
        properties: [
          {id:1},
          {id:2},
          {id:3},
          {id:4}
        ]
      }
    };
    $scope.x = {
      options: [
        {
          id: 1
        },
        {
          id: 2
        }
      ]
    };
  });
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<div ng-app="app" ng-controller="myCtrl">
  <p ng-repeat="(label,field) in app.config.properties">
    <span class="radio-group" ng-repeat="option in x.options">
      {{label}}
    </span>
  </p>
</div>
Pengyy
  • 37,383
  • 15
  • 83
  • 73