In angular, use ng-repeat to loop to output a list, and then you need to obtain a specific parameter value (a numerical value) in each loop section, and then add the total value of the entire loop section. The specific code is as follows:
<li class="opt" ng-repeat="num in data.vote_options track by num.option_id" ng-class="{'finished':'num.is_voted==1','':'num.is_voted==2'}">
<input class="magic-checkbox" type="checkbox" name="{{num.option}}" id="{{num.option_id}}" ng-checked>
<label for="{{num.option_id}}">
<p class="right" ng-bind=num.option>Normal</p>
<p class="progress">
<p class="progress-bar" style="width: 55%; background:#a2d346;"></p>
<span ng-bind="num.voted_num / (num.length).voted_num">55%</span>
<p class="votesnums"><i ng-bind="num.voted_num"></i>票</p>
</p>
</label>
</li>
The 55% in the red circle is the result of rendering according to the above code (number of option votes/number of total votes num.voted_num/num.length.voted_num) It's NaN. Does anyone know how to get the sum of a specific parameter value in the total loop section?
The total number of votes requires background data to be sent to you, or you can calculate it in a loop in your own js. It cannot be calculated in ng-repeat
The command is an interface belonging to the dom and should not be used to maintain data