Wednesday, November 25, 2015

AngularJS $http populating single object

<!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">


    {{ names.userId}}
        {{ names.id}}
   
        {{ names.title}}
   
        {{ names.body}}
   



</div>

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

</body>
</html>

var app = angular.module('myApp1', []);
app.controller('customersCtrl1', function($scope, $http) {
    $http.get("http://jsonplaceholder.typicode.com/posts/1")

  .success(function (response) {$scope.names = response});
});

No comments:

Post a Comment