$q.all create dynamic promises with a loop in angularjs
<p>I want to make a loop which englobe my second promise so every time it pass in my loop a new promise is create:</p>

<pre><code>var promise1 =   $http({
    method: 'GET',
    url: "https://cubber.zendesk.com/api/v2/organizations/"+id+"/users.json",
    dataType: 'json',
    headers: {'Content-Type': 'application/json',
    'Authorization': 'Bearer '+token}

});

var promise2 = promise1.then(function(data) {
    console.log(data);
    for(i = 0; i &lt; data.data.users.length; i++){
            console.log(data.data.users.length);
        var userid = data.data.users[i].id;
            console.log(userid);

       return $http({
            method: 'GET',
            url: "https://cubber.zendesk.com/api/v2/users/"+userid+"/tickets/requested.json",
            dataType: 'json',
            headers: {'Content-Type': 'application/json',
                'Authorization': 'Bearer '+token}

        })
    }
});

$q.all([promise1, promise2]).then(function(data){
    console.log(data[0].data.users, data[1]);
});
</code></pre>

<p>In this code, the loop is not working because <code>promise2</code> only return one result.</p>

<p>Can you help me pls?</p>