angularjs - Read json number and display it in text -
in table display name , points, points comes out in numbers 10,20 , 30 ,40. want if has 10 points, should bronze fellow member in td table {x.ponts} ,20 silver, 30 gold , 40 elite.
you dont need solve it, plenty help did wrong.
<table> <tr ng-repeat="x in id"> <td>{{ x.id }}</td> <td>{{ x.name }}</td> <td>{{ x.points }}</td> </tr> </table> <script> function customerscontroller($scope, $http) { $http.get("mylocalhostlink") .success(function (response) { $scope.number = response });
i thought this... close?
angular.foreach($scope.id, function (value) { switch (value.status) { case 10: $scope.points = bronze; break; case 20: $scope.points = silver; break; case 30: $scope.points = gold; break; case 40: $scope.points= elite; break; default: console.log(value.status); } </script>
try this, need create points
filter. plunker
<td>{{ x.points | points }}</td>
add points filter.
app.filter('points', function() { homecoming function(input) { var point; switch (input) { case 10: point = 'bronze'; break; case 20: point = 'silver'; break; case 30: point = 'gold'; break; case 40: point = 'elite'; break; default: point = 'none'; } homecoming point; }; });
json angularjs
No comments:
Post a Comment