Why does the following code always evaluate Top contributors as true and Contributors as false, even though I can see the member.price and member.amount change? Does anyone have an idea of what I am doing wrong?
<md-virtual-repeat layout-wrap class="toast" ng-repeat="member in members| filter:searchText | orderBy:orderByFunction" >
<div class="subtitle" ng-show="parseInt(member.price) <= parseInt(member.amount)" >
<h2> CONTRIBUTORS {{member.price}} -- {{member.amount}}</h2>
</div>
<div class="subtitle" ng-hide="parseInt(member.amount) <= parseInt(member.price)" >
<h2> TOP CONTRIBUTORS {{member.price}} -- {{member.amount}}</h2>
</div>
I made some changes here:
<md-virtual-repeat layout-wrap class="toast" ng-repeat="member in members| filter:searchText | orderBy:orderByFunction" >
<div class="subtitle" ng-show="showContrib(member) == 1" >
<h2> CONTRIBUTORS {{member.price}} -- {{member.amount}}</h2>
</div>
<div class="subtitle" ng-hide="showTop(member) == 1" >
<h2> TOP CONTRIBUTORS {{Number(member.price)}} -- {{Number(member.amount)}}</h2>
</div>
<md-whiteframe class="md-whiteframe-z3 frieed" style="margin:6px; padding: 19px;" flex-sm="35" flex-gt-sm="25" flex-gt-md="20" layout layout-align="center center">
{{ member.amount}}
</md-whiteframe>
</md-virtual-repeat>
And added this JavaScript code:
$scope.showTop = function(member){
if($scope.topShow == 1){
return 0;
}
if(parseInt(member.price) < parseInt(member.amount)){
console.log('came here price');
$scope.topShow = 1;
return 1;
}
return 0;
};
$scope.showContrib = function(member){
$scope.conShow = 1;
// console.log('price='+member.price+"amount"+member.amount);
if($scope.conShow == 1){
return 0;
}
if(parseInt(member.price) == parseInt(member.amount)){
$scope.conShow = 1;
return 1;
}
return 0;
};
Now, I'm going back to troubleshoot the initial part of the code.