Good day I am trying to read data from the database but its not working properly i need to refresh twice to load the data. And if the data was not load properly the scope.item list stated not define. Thanks
$scope.ItemList = [];
$http({
method: 'GET',
url: 'json/Item.php',
}).success(function (result) {
$scope.ItemList = result;
});
$http({
method: 'GET',
url: 'json/ItemOrder.php?ID=' + $scope.DeliveryID,
}).success(function (result) {
$scope.result = result;
angular.forEach($scope.result, function (value, key) {
var currentIndex = 0;
var index = 0;
var ItemID = value.ItemID;
angular.forEach($scope.ItemList, function (value, key) {
if (value.ItemID == ItemID) {
currentIndex = index;
}
index++;
});
$scope.currentItemId = $scope.ItemList[currentIndex];
});
});