0
這是我寫的html文件,我與產品形象的細節
<div ng-app='myApp' ng-controller='myController'>
<div infinite-scroll='loadMore()' infinite-scroll-distance='2'>
<div ng-repeat="user in users">
<div class="col-md-3">
<div class="panel panel-default text-center">
<img src="../backend/uploads/{{user.image}}" width="200px" height="300px">
<p>{{user.name}}</p>
<span><strong>₹{{user.price}}</strong></span>
</div>
</div>
</div>
</div>
</div>
重複列3 JS 我從PHP文件數據,但它變成無限循環
var myApp = angular.module('myApp', ['infinite-scroll']);
myApp.controller('myController', function($scope, $http) {
//get data from php file
$http({
method: 'get',
url: 'fetch_scroll.php'
}).then(function successCallback(response) {
$scope.users = response.data;
console.log($scope.users);
});
//function to load products
$scope.loadMore = function() {
var length = $scope.users.length;
var last = $scope.users[length - 1];
for(var i = 1; i <= length; i++) {
$scope.users.push(last + i);
}
};
});
控制檯錯誤? –
沒有錯誤我收到了對象格式的數據。它包含名稱,圖像和價格 –
我得到了erroe,即$ scope.users在loadMore函數中未定義 –