angular.js - In angular, use ng-repeat to loop and output a list, then specify a specific parameter value (a numerical value) in the section, and then add the total value of the entire loop section
阿神
阿神 2017-05-24 11:31:57
0
2
1034

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?

阿神
阿神

闭关修行中......

reply all(2)
伊谢尔伦

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

PHPzhong

The command is an interface belonging to the dom and should not be used to maintain data

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template