2016-09-14 27 views
0

我試圖用這個代碼離子密碼dissappearing

<div class="row" id="passwordRow"> 
     <div class=".col-80"> 
      <input type="password" id="password" placeholder="Password" ng-model="user.password" ng-minlength="8" ng-required="true" ng-hide="showPassword" > 
      <input type="text" id="passwordRaw" placeholder="Password" ng-model="password" ng-show="showPassword"> 
     </div> 
     <div class="col"> 
     <i class="icon ion-eye" id="passwordView" on-touch="showPassword = !showPassword"></i> 
     </div> 
</div> 

做這樣的事情

enter image description here

但會發生什麼,如果我輸入的東西,然後按它的第一次展示沒有。如果我輸入並再次按下它,它會顯示正確的值。

我在做什麼錯?

回答

-1

你可以從user.password的這樣刪除用戶:

<div class=".col-80"> 
     <input type="password" placeholder="Password" ng-model="password" ng-minlength="8" ng-required="true" ng-hide="showPassword"> 
     <input type="text" placeholder="Password" ng-model="password" ng-show="showPassword"> 
</div> 

CZ NG-模式應該是相同的兩個在密碼輸入的輸入值

0

分配密碼到控制器範圍中的用戶對象,而在第二個字段中,您從rootScope保留密碼。因爲這裏沒有任何東西,所以它顯示空的輸入。當您將密碼分配給text input時,會在父範圍中創建密碼屬性。問題是這兩個屬性可能不同。恩。你可以第一次設置「abc」到password input,當你點擊按鈕並得到text input時鍵入abcdef。如果再次改回password input你會看到你的password input是3個字母,並沒有5,它有你前面鍵入原始值(「ABC」)