Update screen data after an asynchronous call Angular 1.6

1

I have the following problem! I have a form with an id field. this guy is passed to my GET method which is asynchronous. The data comes back perfectly from the server (line $scope.produto = resposta.data ), but the data is not updated on the screen. Follow the method:

$scope.buscar = function(produto) {
    console.log(produto)
    ProdutosServices.buscar(produto).then(function(resposta) {
        $scope.produto = resposta.data;
    }); 
};
    
asked by anonymous 08.06.2018 / 02:42

1 answer

0
Solved. My response object returned an array. Just change the line:

$ scope.product = response.data

for

$ scope.product = response.data [0]

    
08.06.2018 / 14:43