Why is only the first row is being displayed from JSON list

rikket

I have the following table:

<div data-ng-app="myApp">
    <div data-ng-controller="MyCtrl">
        <form>
            <table>
                <tr>
                    <td><b>ID</b></td>
                    <td><b>Name</b></td>
                    <td><b>Surname</b></td>
                    <td><b>House</b></td>
                    <td><b>Address</b></td>
                    <td><b>Locality</b></td>
                    <td><b>Contact1</b></td>
                    <td><b>Contact2</b></td>
                    <td><b>Contact3</b></td>
                    <td><b>Reply</b></td>
                </tr>
                <tr><td></td></tr>
                <tr ng-repeat="telesale in telesales">
                    <td>{{telesale.ID}}</td>
                    <td>{{telesale.Name}}</td>
                    <td>{{telesale.Surname}}</td>
                    <td>{{telesale.House}}</td>
                    <td>{{telesale.Address}}</td>
                    <td>{{telesale.Locality}}</td>
                    <td>{{telesale.Contact1}}</td>
                    <td>{{telesale.Contact2}}</td>
                    <td>{{telesale.Contact3}}</td>
                    <td>{{telesale.Reply}}</td>
                </tr>
            </table>
        </form>
    </div>
  </div>

controller:

<script type="text/javascript">
  var myApp = angular.module('myApp', []);

  myApp.controller('MyCtrl', ['$scope', '$http', function ($scope, $http) {

      GetPersons();

      function GetPersons() {
          $http({
              method: 'GET',

              url: '/api/data'
          }).
        success(function (data) {
            if (data != null || data != 'undefined') {
                console.log(data);
                $scope.telesales = data;
            }
        })
      .error(function (error) {
          $window.alert("Unable to retrieve people" + error.message);
      });
      }

  } ]);

The data is being retrieved from an api controller which returns a list of 40 objects, however only the first object is being displayed in the table. Why could this be happening?

Screenshot of some of the data retrieved from the api (data crossed out for privacy)enter image description here

It looks as if the second (and the rest of the objects) are being passed as localities which is an foreign key of another tableenter image description here

API Code:

public HttpResponseMessage GetPeople()
    {
        List<CommonLayer.Telesales> list = new BusinessLayer.Telesales().getUserSession(User.Identity.Name);
        //List<CommonLayer.Localities> list = new BusinessLayer.Localities().getAllLocalities();
        if (list.Count > 1)
        {
            return new HttpResponseMessage()
            {
                Content = new StringContent(JArray.FromObject(list).ToString(), Encoding.UTF8, "application/json")
            };
        }
        else
        {
            return null;
        }
    }

Plunkr

sylwester

Please see here http://plnkr.co/edit/fLb9VHrGNqMtouK3dMca?p=preview it's workig but you should tune up your api to get data in better format

 function GetPersons() {
              $http({
                  method: 'GET',

                  url: 'data.json'
              }).
            success(function (data) {
              console.log(data)
                if (data != null || data != 'undefined') {
                    console.log(data[0].Localities.Telesales);
                    $scope.telesales = data[0].Localities.Telesales;
                }
            })
          .error(function (error) {
              alert("Unable to retrieve people" + error.message);
          });
          }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

SQL Server is reading only first row from valid JSON

Is it possible to remove the stroke from being displayed from within the filter only?

Why the icon in QListWidget is displayed only for the first element?

Swift and CSVImporter: Only the first row of .csv is being imported

Why is only the first word in records being matched?

why it only "see's" the first row?

Removing words from list, only first if statement is being executed

why mouseover only works for the first row

Why is only the first record being returned from this PHP array?

Only first row from array being added to database Java

Why only the First Element is being added to the div

.bat file: only the first line is being executed - why?

Why is my padding not being removed only from the first child

Only final row of array being displayed

How to prevent empty item in list from being displayed?

Why Is My C# Code Only Displaying The First Row from my Database?

List component displays only the first row

Why is the stub only being used in the first test?

Why is only one row from this query displayed?

Why body from the first modal displayed in the second?

Why aren't my images being displayed in the same row?

Prevent null values from being displayed on API JSON response

Jasper report - the first line from a list is not displayed

Why does javascript onchange event only work in first row update from a data table

Why isn't my list of users being displayed?

Take only first row from sets of rows

My images are not being displayed in a row

Why are my list items not being displayed on listView (Android)

Only the first row of annotations displayed on seaborn heatmap