Hey there, I'm currently working on a web application using AngularJS and I'm facing an issue with querying arrays. Check out the code snippet below:
var angulararray = [];
bindleaselistings.bindleaselistingsmethod().then(function(response) {
angular.forEach(response.data.data.LeaseList, function(value, key) {
angulararray.push(value);
});
}, function(error) {});
console.log(angulararray);
debugger;
var found = $filter('filter')(angulararray, {
id: accountnumber
}, true);
if (found.length) {
$scope.selected = JSON.stringify(found[0]);
} else {
$scope.selected = 'Not found';
}
The console.log shows the expected array content. I've included a screenshot for reference https://i.sstatic.net/QDs8a.png
While debugging the line
var found = $filter('filter')(angulararray, { id: accountnumber }, true);
, I noticed that angulararray appears to be empty. Can anyone point out what might be wrong in my code? Any assistance would be greatly appreciated. Thank you!