First, I am sorry for my bad English. I am new in angular js. I am facing a problem with my api call inside loop. This is my code demo.
    $http
    .get("http://localhost:8000/api/product-track/get-product-phase-item/" + item_id, {
        transformRequest: angular.identity,
        headers: {'Content-Type': undefined, 'Process-Data': false}
    })
    .then(function(response){
        data = response.data.item_category;
        $scope.items = response.data.data;
        angular.forEach($scope.items, function(item){
            $http
                .get("http://localhost:8000/api/item/get-item-name/" + item.item_category_id, {
                    transformRequest: angular.identity,
                    headers: {'Content-Type': undefined, 'Process-Data': false}
                })
                .success(function (response) {
                    data = response;
                    console.log(data);
                });
        });
    });
Now i explain what problem i am faced with that code. My first api call perfectly. When my second api call inside loop it also execute perfectly. But when the value of item.item_category_id is same, i am facing problem. Then my api does not call sequentially. I don't know, have i explained my problem correctly.
I am given an example. When my loop execute 5 times and the urls are-
- http://localhost:8000/api/item/get-item-name/2"
- http://localhost:8000/api/item/get-item-name/4"
- localhost:8000/api/item/get-item-name/5"
- localhost:8000/api/item/get-item-name/4"
- localhost:8000/api/item/get-item-name/4"
- localhost:8000/api/item/get-item-name/6"
Then i got response first no 1 then 2 then 3 then 6 then 4 then 5. When the id is repeated it does not response sequentially.Why i am faced this problem. Thanks...
 
     
    