Angularjs, after select, save to another table

Asked

Viewed 126 times

2

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

address_codigo: 453114, bairro_codigo: 15698, address_cep: 17052330,...

I have another function called salvar, where you save this data along with other data typed in my BD. How do I show in my capos that they should be self filled?

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 the quest to complete this field for me to save.

  • When it searches the bd, you are setting the values returned in the variables used as ngModel?

1 answer

2

You must save the return in $Scope and use ng-model in 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" >

Browser other questions tagged

You are not signed in. Login or sign up in order to post.