javascript - Angular method executes indefinitely when it uses with the ng-style -
html
<div class="progress-bar" ng-style="{width: event.methods.getprogress() + '%'}"></div>
js
getprogress: function () { var total = number($scope.event.item.total); var goal = number($scope.event.item.goal); if (total > goal) { total = goal; } return math.round((total / goal) * 100); },
i have used above code show progress bar on page.progress bar working fine.but when put debug point on getprogress()
method executes indefinitely.when remove ng-style
there no problem (but know progress bar not working).so tell me how avoid above kind of behaviour ? in advance.
html
<div class="progress-bar" ng-style="{width: progressvalue + '%'}"></div>
js
//initially setup value $scope.progressvalue = 0; //then on every call of getprogress updated getprogress: function () { var total = number($scope.event.item.total); var goal = number($scope.event.item.goal); if (total > goal) { total = goal; } $scope.progressvalue = math.round((total / goal) * 100); },
Comments
Post a Comment