Wednesday, November 25, 2015

AngularJS $http populating list objects

<!DOCTYPE html>
<html>
<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<body>

<div ng-app="myApp1" ng-controller="customersCtrl1">

<ul>
  <li ng-repeat="x in names">
    {{ x.Name + ', ' + x.Country }}
  </li>
</ul>

</div>

<script src="js/personController.js"></script>

</body>
</html>

var app = angular.module('myApp1', []);
app.controller('customersCtrl1', function($scope, $http) {
  $http.get("http://www.w3schools.com/angular/customers.php")
  .success(function (response) {$scope.names = response.records;});
});

No comments:

Post a Comment