0

I have a search controller that I am using:

function searchRes($scope, $http, API, CarDetailService, $state){

  $scope.$watch('search', function() {
    fetch();
  });

  $scope.currentPage = 1;
  $scope.pageSize = 5;

  function fetch(){
    $http.get(API + "/search/" + $scope.search)
    .then(function(response){ 
      $scope.details = response.data;
    });
  }

  $scope.select = function(){
    this.setSelectionRange(0, this.value.length);
  }

  $scope.selectCar = function(carId) {
    CarDetailService.setCar(carId);
    $state.go('taskDetails');
  };

}

Here is the HTML:

<div ng-controller="searchRes" class="mainSearch">

  <div class="searchBar">
    <input type="text" ng-model="search" onclick="select()" placeholder="Enter Search Term" autofocus />
  </div>

  <div ng-repeat="res in details.Search">
    <div>{{ res['Display Name'] }}</div>
  </div>

</div>

I have tried:

ng-repeat="res in details"
ng-repeat="res in response.data"
ng-repeat="res in data"
ng-repeat="res in response"
ng-repeat="res in response.data.Results"
ng-repeat="res in details.data.Results"

Here is an image of what the API returns (data.Results):

enter image description here

EDIT when I do a console.log(response); I can see all the JSON data being returned (data.Results)

I know I am obviously not calling the data properly but I don't know what else to try which i guess is why I am here.

7
  • $scope.fetch = function() ? Commented Aug 16, 2016 at 16:00
  • What is the structure of response.data? An Array? An Object? Please post. Commented Aug 16, 2016 at 16:04
  • data.Results. Its an object and inside that object is the array that I am trying to loop through. I have edited my question. Thanks for pointing that out. I forgot to add it. Commented Aug 16, 2016 at 16:15
  • 2
    ng-repeat="res in details.Results" ? Commented Aug 16, 2016 at 16:21
  • @cventr damn, one minute too late. Commented Aug 16, 2016 at 16:23

1 Answer 1

3

You need ng-repeat="res in details.Results".

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks you so much for your help. Thumbs up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.