0

I want to get value from this JSON response into angular js object.

[{"label":"Test","value":""," Test2":"","required":"mandatory","type":"text","typeemail":""}]

into angularjs object, here is .html

<tr ng-repeat="item in searched = (coba | filter:customerid | filter:search ) | coba:(currentPage-1)*itemsPerPage |limitTo:viewby ">
    <td>
      <p>{{item.additionaldata_pay}}</p>
    </td>
</tr>

here is .js file

app.controller("cobacont", ['$scope','$http',function($scope,$http) {
      $scope.cari = function () {
        $http.get('...a='+$scope.month).then(function(response){
          $scope.coba = response.data; 
        });
      }  
}]);
4
  • Can you console.log(coba) in your controller ? Does your html target the right controller ? Should not you iterate on Controller.coba instead of searched ? Commented Nov 3, 2017 at 9:49
  • (90) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}] . Here is The Result when i console.log(coba) Commented Nov 3, 2017 at 10:02
  • Can you do console.log(coba[0])? That will explain a lot about your data structure. Commented Nov 3, 2017 at 10:12
  • ya, but in the last record there is a json value like above. so i wanna get the value of that record. Commented Nov 3, 2017 at 10:23

2 Answers 2

1
var app = angular.module('main-App', []);
app.controller('customersCtrl', function($scope,$http) {

$scope.records = [];

$http.get("https://...a='+$scope.month")
  .then(function (response) {
     console.log(response.data);
     $scope.records = response.data;
  });
});

here is my html table

<tr dir-paginate="value in data | itemsPerPage:5" total-items="totalItems"  ng-repeat="user in records">
    <td>{{$index+1}}</td>
    <td >{{user.label}}</td>
    <td >{{user.value}}</td>
    <td>{{user.required}}</td>
    <td>
        <button data-toggle="modal" data-target="#edit-data" class="btn btn-primary" ng-click="selectedUser(user)">Edit</button>
        <button ng-click="DeleteUser(user)" class="btn btn-danger" data-toggle="modal" data-target="#delete-data">Delete</button>
    </td>
</tr>
Sign up to request clarification or add additional context in comments.

2 Comments

or else u pass in method too->>>ids-fe1.com/MonitoringAPI/webresources/…
i have tried what you said, with little bit approach. but it seems doesnt work. sorry for bad english
0

It's best that you put all data processing in your controller. And leaving the HTML to display your data only.

So, in your controller, add another method that will do your search, filter, and pagination, and the result can then be used in your view.

$scope.getData = function () {
   var data = $filter('filter')($scope.coba, $scope.searchQuery);
   // do pagination here...
   return data;
}

Your HTML can then become something like this:

<tr ng-repeat="item in getData()">
    <td>
        <p ng-bind="item.additionaldata_pay"></p>
    </td>
</tr>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.