2016-12-19 28 views
0

在此代碼:使用角度輸入掩碼的兩倍時間,隨後

<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> 

當我完成了另外兩個具有相同的值中的任何一個,我該怎麼改變呢?

回答

0

因爲兩者都有相同的模型,提供不同的模型,每個輸入將解決這個問題。您也可以使用對象並綁定這些鍵。

<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> 
0

這只是因爲您的兩個輸入都使用相同的ng-model。只需設置一個不同的應該幫你

0

ng-model定義了將由您的輸入編輯的變量。

因此,如果您輸入具有相同ng-model,它將編輯相同變量。


在這裏,你只需要改變你的第二個輸入的NG-型號:

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