AngularJS, after select, save in another table

2

I created a function called buscarCep() which returns me the following object:

  

address_code: 453114, code_code: 15698, address_cep:   17052330, ...

I have another function called salvar , where it saves this data along with others typed in my BD . How do I show in my bosses that they should be auto-populated?

Example:

< input name="endereco" class="form-control" type="text" ng-model="cadastro.endereco.endereco" maxlength="60" >

If you enter something in this input, save it right in my BD , but I wanted it to fetch this field for me to save.

    
asked by anonymous 27.04.2016 / 17:03

1 answer

2

You should save the return on $ scope and use ng-model on the inputs.

For example:

$scope.resultado = obj; // obj que retornou sua função  buscarCep();


< input name="endereco" class="form-control" type="text" ng-model="resultado.endereco_codigo" maxlength="60" >
    
27.04.2016 / 17:48