gpt4 book ai didi

javascript - Angular - ng-repeat 不适用于搜索 Controller

转载 作者:行者123 更新时间:2023-11-28 18:26:42 25 4
gpt4 key购买 nike

我正在使用一个搜索 Controller :

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');
};

}

这是 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>

我已经尝试过:

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"

以下是 API 返回内容的图像(数据.结果):

enter image description here

编辑 当我执行 console.log(response); 时我可以看到返回的所有 JSON 数据 (data.Results)

我知道我显然没有正确调用数据,但我不知道还能尝试什么,我想这就是我在这里的原因。

最佳答案

您需要ng-repeat="res indetails.Results"

关于javascript - Angular - ng-repeat 不适用于搜索 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38979442/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com