mardi 22 novembre 2016

Select precise data's value in JSON object using AngularJS

Currently new & working on a web app using AngularJS, using Nginx serv.

I want to select some precise values to put them in a html table.

I kept searching and never find an adequate solution.

Do you have an idea on how can I make this work?

Here's the code:

<!DOCTYPE html>
<html>
    <head>
        <script src="http://ift.tt/2bbQWFE"></script>
        <script>
        var app = angular.module('app', []);
        app.controller('myCtrl', function($scope, $http) {
          $http.get('variables.json').success(function(data) {
                 $scope.variables = data;
          });
        });
        </script>
    <link rel="stylesheet" type="text/css" href="../app/css/style.css">
  </head>
    <body ng-app="app" ng-controller="myCtrl" ng-init="variables">
      <ul>
        <li ng-repeat="var in variables">
          
          
        </li>
      </ul>
    </body>
</html>

JSON File:

 {
  "a":6084.0,
  "b":979
 }

I just put an example of the JSON file. My purpose is to display for example just the b or a value.




Aucun commentaire:

Enregistrer un commentaire