0

In this code:

<div class="list">
    <label class="item item-input">
        <span class="input-label">CEP Origem: </span>
        <input type="text" id="origem" ng-model="cep" ui-br-cep-mask>
    </label>
    <label class="item item-input">
        <span class="input-label">CEP Destino: </span>
        <input type="text" id="destino" ng-model="cep" ui-br-cep-mask>
    </label>
</div>

When I completed any one of the two the other have the same value, how can I change this?

3 Answers 3

1

Because both have the same model, provide different model for each input will solve this issue. You can also use object and bind the keys.

<div class="list">
  <label class="item item-input">
    <span class="input-label">CEP Origem: </span>
    <input type="text" id="origem" ng-model="cep.origem" ui-br-cep-mask>
  </label>
  <label class="item item-input">
    <span class="input-label">CEP Destino: </span>
    <input type="text" id="destino" ng-model="cep.destino" ui-br-cep-mask>
    </label>
</div>
Sign up to request clarification or add additional context in comments.

Comments

0

This is simply because both of your inputs are using the same ng-model. Simply set a different one should help you

Comments

0

ng-model defines the variable that will be edited by your input.

So, if your inputs have the same ng-model, it will edit the same variable.


Here you just have to change the ng-model of your second input:

<input type="text" id="origem" ng-model="cep1" ui-br-cep-mask>
<input type="text" id="destino" ng-model="cep2" ui-br-cep-mask>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.