json value not fetching from localhost to angularjs frontend

by Pasan Ratnayake

HTML

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
<!-- the ngApp tag is in the body -->
<div ng-controller="testController">
    I have changed nothing other than the url in your code. It works - so if it doesn't work on yours. Perhaps you should check your code again
<ul>
  <li ng-repeat="data in names">
    {{ data.name + ', ' + data.email }}
  </li>
</ul>
</div>

JavaScript

angular.module('testApp.services', []);
angular.module('testApp.directives', []);
angular.module('testApp.controllers', ['testApp.services', 'testApp.directives']);
angular.module('testApp', ['testApp.services', 'testApp.controllers', 'testApp.directives']);

/*
 * To declare a directive
 * angular.module('testApp.controllers').directive('testDirective', function() { return {}; });
 * 
 * To declare a service
 * angular.module('testApp.services').factory('testService', function() { return {}; });
 */
// 

angular.module('testApp.controllers').controller('testController', ['$scope', '$http', function ($scope, $http) {
    $scope.name = 'CodeHawkz';
    $scope.names = [];
    
    $http.get('http://jsonplaceholder.typicode.com/users').then(function (result) {
        $scope.names =result.data;
    });
}]);