Having the following structure, HOW DO I do it to print the amount of stars that each car has? that is. IF in the json it says "stars": "3" would have to print 3 labels
The expected result is to print 3; The first with 3 inside. The second with 4 inside and the last with 2 inside.
Please help!
** app.js | data.json | HTML **
var app = angular.module("app", []);
app.controller("appController", function($scope, $http) {
$http.get('/data.json').success(function(data) {
$scope.autos = data.autos;
});
});
{
"Autos" : [
{
"name" : "BMW",
"stars" : "3",
},
{
"name" : "Ferrari",
"stars" : "4",
},
{
"name" : "Ford",
"stars" : "2",
}
]
}
<html lang="en" ng-app="app">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
</head>
<body ng-controller="appController">
<div>
<i ng-repeat="star in autos" class="fa fa-star"></i>
</div>
</body>
</html>