Angular JS - AJAX Sample

<html>
   <head>
      <title>Angular JS Test</title>
     
      <style>
         table, th , td {
            border: 1px solid grey;
            border-collapse: collapse;
            padding: 5px;
         }
         
         table tr:nth-child(odd) {
            background-color: #f2f2f2;
         }
         
         table tr:nth-child(even) {
            background-color: #ffffff;
         }
      </style>
     
   </head>
   <body>
      <h2>AngularJS Sample Application</h2>
      <div ng-app = "" ng-controller = "currencyController">
     
         <table>
            <tr>
               <th>Name</th>
               <th>valueForUSD</th>
               <th>inverse</th>
            </tr>
         
            <tr ng-repeat = "currency in currencies">
               <td>{{ currency.currencyName }}</td>
               <td>{{ currency.valueForUSD }}</td>
                           <td>{{ currency.inverse }}</td>
             
            </tr>
         </table>
      </div>
     
      <script>
         function currencyController($scope,$http) {
            var url = "<REST URL >";//"http://localhost:8080/ExchangeApp/rest/exchange/list";
         
            $http.get(url).success( function(response) {
               $scope.currencies = response;
            });
         }
      </script>
     
      <script src = "http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>
     
   </body>
</html>
Technology: 

Search