I'm new to programming and this is my first question I've had to post.
What I'm trying to do is use ng-bind-html to place five image files into the div that is being created by ng-repeat. These five image files will differ between each element from the ng-repeat.
<div ng-repeat = "newGame in myGamesList">
<div class="col-sm-4 col-lg-4 col-md-4">
<div class="thumbnail">
<div>
<img src="{{newGame.thumbnail}}" alt="">
</div>
<div class="caption">
<h4 class="pull-right">{{newGame.price}}</h4>
<h4><a ng-style="{'font-size': nameSize((newGame.name | removeSubName).length)}" class="categoryGameName" href="#details/{{myGamesList.indexOf(newGame)}}">{{newGame.name | removeSubName}}</a>
</h4>
<p>{{newGame.description}}</p>
</div>
<div id="ratingDiv" style="margin-left: 8px; margin-right: 8px; margin-bottom: 5px;">
<div style="display: inline-block" ng-bind-html="trustedHtml"></div>
<p class="pull-right" style="color: #d17581">{{newGame.numberReviews}} reviews</p>
</div>
</div>
</div>
</div>
I also have this in myApp, and no problems with sce being undefined etc.
$scope.html = getStars(newGame);
$scope.trustedHtml = $sce.trustAsHtml($scope.html);
If I replace the newGame in getStars(newGame) with something defined under the scope the code works, however using newGame (trying to match with the temporary variable from ng-repeat = "newGame in myGamesList"), nothing appears.
How can I make it so newGame is recognized as each element that is being iterated upon?
The function getStars has the following code
$scope.getStars = function(game) {
var numStars = (game.numberStars);
iconString = '';
for (i=0; i<Math.floor(numStars); i++) {
iconString += '<img style="width:16px" class="starGlyph" src="images/fullStar.png" alt=""/>'
}
if (numStars%1 == 0.5) {
iconString += '<img style="width:16px" class="starGlyph" src="images/halfStar.png" alt=""/>'
}
for (j=0; j<(5-Math.ceil(numStars)); j++) {
iconString += '<img style="width:16px" class="starGlyph" src="images/emptyStar.png" alt=""/>'
}
return iconString;
};
In case that is helpful. To clarify, I need each newGame in myGamesList to be the parameter that is input to the getStars function.
Sorry if this is hard to follow, but I tried to cover all my bases!