0

Here my angular code:

//first ng repeat
$http.get(server_base_url + "api/v1/testsectionlist/" + $scope.instslug + "/" + $scope.test Slug)
`enter code here`
.success(function(section Data) {
  $scope.section Data = section Data;
})
//second ng repeat 
$http.get(server_base_url + "api/v1/correctques/" + $scope.testSlug + "/" + $scope.test Id)
  .success(function(correct ques) {
    $scope.correct cues = correct ques;
    //console.log($scope.correct ques); 
  })

<div class="col-xs-4" style="padding-left: 0px; padding-right: 0px;" ng-repeat="sectionView in sectionData">
  <div class="card" style="height: 175px;">
    <div class="card-heading">
      <h2 style="text-transform: uppercase;">{{sectionView.section}}</h2>
    </div>
    <div class="list-group list-group-lg no-bg">
      <a href="" class="list-group-item text-ellipsis">
        <span class="pull-right" ng-repeat="sectionscoreData in correctques">
   <span ng-if="sectionView.sectionId == sectionscoreData.sectionId && sectionscoreData.answer == sectionscoreData.selectOption">{{sectionscoreData.sectionId}}</span>
        </span>
      </a>
    </div>

I'm using two ng-repeat and check multiple condition but, not counting total id in my span ng-if condition. Can anyone help me to count the array length for ng-if multiple conditions and also use multiple ng repeats?

Thanks in advance.

Mistalis
  • 17,793
  • 13
  • 73
  • 97

1 Answers1

0

Rather than using ng-if you should use a filter on the ng-repeat so that it only includes the matching values. $index on the last item will give you the count, but it would be better to create an array of filtered items and look at it's length. See this question and answer: Using ng-repeat and filter, how to tell which items are visible? for details on how to do that.

Mike Feltman
  • 5,160
  • 1
  • 17
  • 38