0

Actually, Fetch the data but unable to visible in HTML code. In the web browser console displays the json data. but not visible in HTML code. this is my angular js code

$scope.refresh = function(){
    fetchData();
};

$scope.fetchData = function(){
    $http.get('index').success(function(data){
         console.log(data);
        $scope.namesData = data;
    });
};

This is the HTML code

<tr data-ng-repeat="name in namesData">
   <td><span>{{name.first_name}}</span></td>
   <td><span>{{name.last_name}}</span></td>

Totally seven records in the database, it displays seven blank space. Not visible in JSON data in HTML.

georgeawg
  • 48,608
  • 13
  • 72
  • 95
Vignesh_E
  • 167
  • 2
  • 4
  • 15
  • The [`.success` method is deprecated](https://stackoverflow.com/questions/35329384/why-are-angularjs-http-success-error-methods-deprecated-removed-from-v1-6/35331339#35331339). – georgeawg Apr 14 '19 at 07:45
  • 1
    Post the result of `console.log(data);` – Sudhir Ojha Apr 14 '19 at 08:30
  • {id: 0, firstname: "John", lastname: "Smith", $$hashKey: "object:6"} 1: {id: 0, firstname: "Moore", lastname: "David", $$hashKey: "object:7"} 2: {id: 0, firstname: "Peter", lastname: "Parker", $$hashKey: "object:8"} 3: {id: 0, firstname: "Guadalupe", lastname: "Bolan", $$hashKey: "object:9"} 4: {id: 0, firstname: "Austin", lastname: "Miller", $$hashKey: "object:10"} 5: {id: 0, firstname: "Steave", lastname: "Smith", $$hashKey: "object:11"} 6: {id: 0, firstname: "vignesh", lastname: "waran", $$hashKey: "object:12"} length: 7 __proto__: Array(0) – Vignesh_E Apr 14 '19 at 10:12

1 Answers1

0

The properties in your json are firstname and lastname but in your html, you're displaying first_name, last_name, you should do something like this :

<tr data-ng-repeat="name in namesData">
   <td><span>{{name.firstname}}</span></td>
   <td><span>{{name.lastname}}</span></td>
</tr>

Working jsfiddle

Abdelkarim EL AMEL
  • 1,515
  • 1
  • 10
  • 10
  • thank you very much, it works. I created a table in this format create table(first_name varchar(10), last_name varchar(10)); But JSON data retrieve from same variable like first_name, last_name. I don't know how came like firstname, lastname – Vignesh_E Apr 14 '19 at 10:47
  • the json is a representation of your entity, which doesn't have underscores i guess, and no `@JsonProperty` annotation, right ? – Abdelkarim EL AMEL Apr 14 '19 at 10:50