ng-repeat - count within html loop

前端 未结 4 1539
后悔当初
后悔当初 2021-01-02 20:04

Is there anyway to count an item, then display it outside of the loop?


   value.total
         


        
4条回答
  •  情歌与酒
    2021-01-02 20:42

    You can make use of $parent notation to access a $scope variable (from outside ng-repeat) in the ng-repeat scope. So now after initializing it will calculate the total and store it in the $scope variable which was initialized outside.

    Code:

    {{value}}
    Total Of All Values: {{ total }}

    Working Fiddle

提交回复
热议问题