我有一个控制器,它会迭代页面以创建滚动。
var i=1;
$scope.result=[];
$scope.loadMore = function(){
$http.get( "http://test.website.com/api/search/"+i).success(function(response){
i++;
$scope.result.push(response);
console.log(response);
$timeout(function () {
$scope.result = response;
});
$scope.$broadcast('scroll.infiniteScrollComplete');
});
}
我想在我的视图中将返回的json对象推送到结果中:
<div class="item item-text-wrap" ng-click="post($event,res)" ng-repeat="res in result" ng-model="text" ng-controller="recommendedJobsCtrl" >
我还在底部添加了以下内容:
<ion-infinite-scroll ng-if="!noMoreItemsAvailable" on-infinite="loadMore()" distance="10%"></ion-infinite-scroll>
console.log中的数据显示正确的信息,但我不认为它被推送到结果。有人可以建议吗?
我的console.log输出此
[Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object]
和ech对象包含:
"id":1396702,
"employer_id":74801,
"external_id":null,
"view":449,
"apply":22,
"status":1,
"rank":1,
"type":"C",
"notification_type":4,
"package":2,
"locality":"MY",
"locality_city":"Kuala Lumpur",
"category":"adm",
"subcategory":null,
"level":0,
"experience":0,
"country":"MY",
"zip":null,
"area":"Kuala Lumpur",
"state":null,
"city":null,
"salary_min":1000,
"salary_max":1100,
"salary_period":2,
"salary_currency":"MYR",
"logo_url":"\/\/s3.amazonaws.com\/JHP-S3\/uploads\/image\/90821\/1owQih5MsM\/plogo",
"banner_url":"",
"company_url":null,
"company_email":"shareen@mymillenniumjobs.com",
"company":"1Millennium International Sdn Bhd",
"industry":0,
"title":"Telephone Operator - Kuala Lumpur",
"summary":null,
"description":"
Attend to customers' incoming calls and provide solutions in a timely manner.<\/li>\n
SPM Cerificate<\/li>\n
Good spoken English<\/li>\n
5 days work - Monday to Friday<\/li>\n
Working hours - 8:45am to 5:45pm<\/li>\n
People oriented and able to work well in team<\/li>\n
Basic salary 1000 + attendance allowance<\/li>\n
Working Location - around Kuala Lumpur (LRT or monorail accessible)<\/li>\n
Calling all school leavers keen in part-time work<\/li>\n<\/ul>",
"published_at":"2016-07-11 01:41:52",
"refreshed_at":"2016-07-11 01:41:52",
"created_at":"2016-04-04 06:55:17",
"updated_at":"2016-07-11 01:49:28"
},
答案 0 :(得分:1)
尝试此操作确保响应不包含任何对象。如果它包含在数据对象中,那么您可以使用if(data) {x = JSON.parse(x);}
<强> HTML 强>
data.response
<强> CONTROLLER 强>
<ion-content>
<ion-list>
<ion-item ng-repeat="item in items">
{{item.title}}
</ion-item>
</ion-list>
<ion-infinite-scroll
on-infinite="loadMore()"
distance="1%">
</ion-infinite-scroll>
</ion-content>