SELECT HTML does not update after receiving data (Angularjs)

Asked

Viewed 39 times

0

I have a select HTML in my project and use Angularjs

<div class="form-group col-sm-3">
    <label>Natureza Operação:</label>
    <select ng-model="comprasConsumivelUnico.compras.naturezaEntrada" ng-change="replaceCtbOperacao(comprasConsumivelUnico.compras.naturezaEntrada, natureza)" ng-options="nat.Natureza as nat.Natureza +' - '+ nat.DescNatureza for nat in natureza | orderBy:'DescNatureza'" ng-required="true">
        <option value="">Selecione Natureza</option>
    </select>
</div>

Then I make a request in the bank and it adds the value 200 to my ng-model ng-model="comprasConsumivelUnico.compras.naturezaEntrada" this has the value, but the selector gets the default value instead of the value of the ng-model.

Como fica o select html quando realizo uma consulta

Then after I simply pass a TAB over it it assigns the correct value:

Select após simplesmente passar o TAB

I would like to, when consulting a request, bring the information to the select of the value that came from the bank.

Can you help me?

1 answer

0

From what I understand, I could remove the concatenation from the string, and use only the second part.

Your current code:

ng-options="nat.Natureza as nat.Natureza +' - '+ nat.DescNatureza for nat in natureza | orderBy:'DescNatureza'"

A possible solution:

ng-options="nat.DescNatureza for nat in natureza | orderBy:'DescNatureza'"

Browser other questions tagged

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