AngularJS Http get empty first time
<p>I have this code</p>

<pre><code>PedidosService.getProductbyID($scope.listProductos.ProductID).then(function (d) {
            $scope.oneProduct = d.data.producto;                
        });
</code></pre>

<p>PedidosService is the name of my factory, getProductbyId is my http get request and $scope.oneProduct is the variable where i want store the result of this request.</p>

<pre><code>factory.getProductbyID = function (id) {
    return $http.get('/Pedidos/GetProduct/' + id);
}
</code></pre>

<p>factory is my Factory and getProductbyID is my function to call http request</p>

<p>I call this code in a button. The first time that I click in the button, it returns a empty response '[]' but the next times that I click the button, it works fine!!!.</p>

<p>Thanks for you help</p>