So, I have a problem with this code and I don`t know why I get that error
$scope.veilingen = {};
$http.get('./helpers/get/Veilingen.php').
success(function(data) {
if(debugMode) console.log(data);
$scope.veilingenCache = data;
for(var i = 0; i < 2; i++) {
console.log($scope.veilingen)
$scope.veilingen.push({
test: 'hello'
});
console.log($scope.veilingen)
}
});
I get this error:
TypeError: undefined is not a function at http://example.com/includes/controllers/veilingCntrl.js:12:30 at http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.18/angular.min.js:72:72 at I (http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.18/angular.min.js:100:144) at I (http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.18/angular.min.js:100:144) at http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.18/angular.min.js:101:308 at k.$eval (http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.18/angular.min.js:112:32) at k.$digest (http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.18/angular.min.js:109:121) at k.$apply (http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.18/angular.min.js:112:362) at h (http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.18/angular.min.js:72:327) at x (http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.18/angular.min.js:77:288)
Line 12 is the push() area. I have searched why this happens but I can`t find it. What I want is that the object veilingen gets the first 2 results and after its load the user can change it with:
$scope.setLimitVeiling = function(items) {
for(var i = 0; i < items; i++) {
$scope.veilingen.push($scope.veilingenCache[i]);
}
}
But yeah, if push is not working...?
$scope.veilingen
is declared as an object instead of array.
$scope.veilingen = [];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With