Print data from local json with angularjs

Viewed 59

I am new at angularjs and I want to post in a table the data from my local json. I tried this method but when I open the console browser I have an error: Cannot read property 'id' of undefined

<html ng-app="GithubApp">

<head>
<meta charset="utf-8">
<title></title>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.min.js"></script>
<script>
var countryApp = angular.module('GithubApp', []);
countryApp.controller('GitCtrl', function ($scope, $http) {
  $http.get('JSONdate.json').success(function (data) {
    $scope.gits = data;
  });
});

<body ng-controller="GitCtrl">
  <table>
   <tr>
  <th>Id</th>
  <th>Login Name</th>
  <th>Email</th>
  <th>Public Gits</th>
  <th>Html Profile</th>
  <th>Avatar URL</th>
</tr>
<tr ng-repeat="git in gits">
  <td>{{git.id}}</td>
  <td>{{git.login_name}}</td>
  <td>{{git.email}}</td>
  <td>{{git.public_gits}}</td>
  <td>{{git.Html_profile}}</td>
  <td>{{git.Avatar_URL}}</td>
  </tr>
</table>
</body>

</html>

Here is a pice of my json, and how my data is structured.

[
   {
      "id":"0",
      "login_name":"jk3064",
      "public_gits":"0",
      "Html_profile":"LINK",
      "Avatar_URL":"LINK"
   },
   {
      "id":"1",
      "login_name":"hoijui",
      "public_gits":"5",
      "Html_profile":"LINK",
      "Avatar_URL":"LINK"
   },
   {
      "id":"2",
      "login_name":"abma",
      "public_gits":"11",
      "Html_profile":"LINK",
      "Avatar_URL":"LINK"
   },
   {
      "id":"3",
      "login_name":"tvo",
      "email":"tobivollebregt@gmail.com",
      "public_gits":"1",
      "Html_profile":"LINK",
      "Avatar_URL":"LINK"
   },
   {
      "id":"4",
      "login_name":"zerver",
      "public_gits":"0",
      "Html_profile":"LINK",
      "Avatar_URL":"LINK"
   }
]

If you can say what is the error, and what should i modify in the project to make it work. Please help

2 Answers
Related