Hello, I'm a newcomer to AngularJS and I have the following code snippet in HTML:
// Here, I have another ng-repeat loop where I compare home.home_info_id with avg.home_inof_id
<div ng-repeat='home in homeDetailInfo'>
<div ng-repeat="avg in homerating">
<div ng-if="avg.home_info_id==home.home_info_id">
<div class="star" ng-modal="avg" data-score="{{avg.avg}}"></div>
</div>
</div>
I am getting the following data:
hallrating=[
{"home_info_id":"94","avg":"3.33333333333333"},
{"home_info_id":"119","avg":"4"},
{"home_info_id":"95","avg":"4.5"}
]
It works perfectly for three homes, but the issue arises with the fourth home as it has not been rated yet. I need to display data-score='0' for that home. I have attempted the following:
<div ng-repeat='home in homeDetailInfo'>
<div ng-repeat="avg in homerating">
<div ng-if="avg.home_info_id==home.home_info_id">
<div class="star" ng-modal="avg" data-score="{{avg.avg}}"></div>
</div>
<div ng-if="avg.home_info_id!=home.home_info_id && avg.avg!=''">
<div class="star" ng-modal="avg" data-score="0"></div>
</div>
</div>
This did not work for me so I also tried:
<div ng-repeat='home in homeDetailInfo'>
<div ng-repeat="avg in homerating">
<div ng-if="avg.home_info_id==home.home_info_id">
<div class="star" ng-modal="avg" data-score="{{avg.avg}}"></div>
</div>
<div ng-if="!avg.avg">
<div class="star" ng-modal="avg" data-score="0"></div>
</div>
</div>