2016-12-28 15 views
0

控制我有創建行的角度表:如何設置輸入掩碼當角generete在

<tr ng-repeat="rowContent in rows" class="gridRow"> 
    <td> 
     <input type="text" id="txtCompanyTitle" class="form-control" ng-model="CompanyTitle" /> 
    </td> 
    <td> 
     <input type="text" id="txtCompanyTaxes" class="form-control currencyMask" ng-model="CompanyTaxes" /> 
    </td> 
    <td> 
     <button type="button" ng-click="deleteRow(rowContent)" class="btn btn-danger btn-sm"> 
      <span class="glyphicon glyphicon-trash"></span> 
     </button> 
    </td> 
<tr> 

<button type="button" class="btn btn-default btn-sm" ng-click="addRow()"> 
    <span class="glyphicon glyphicon-plus"></span> Add 
</button> 

我需要使用設置txtCompanyTaxes的面具:

$(".currencyMask").inputmask('currency', { 
    prefix: '', 
    groupSeparator: '@Global.Mask_NumberGroupSeparetor', 
    radixPoint: '@Global.Mask_NumberRadixPoint', 
    autoGroup: true 
}); 

我做請嘗試下面的內容,但是在創建下一行時(最後一行永遠不會獲得掩碼)它只在當前行上工作:

<script> 
    var myApp = angular.module('MyApp', []) 

    myApp.controller('Companies', ['$scope', function ($scope) { 

     $scope.rows = ['Row 1']; 
     $scope.counter = 2; 

     $scope.addRow = function() { 
      $scope.rows.push('Row ' + $scope.counter); 
      $scope.counter++; 
      $(".currencyMask").inputmask('currency', { 
       prefix: '', 
       groupSeparator: '@Global.Mask_NumberGroupSeparetor', 
       radixPoint: '@Global.Mask_NumberRadixPoint', 
       autoGroup: true 
      }); 
     } 

     $scope.deleteRow = function (item) { 
      if (confirm("@Global.Form_AreYouSure")) { 
       var index = $scope.rows.indexOf(item); 
       $scope.rows.splice(index, 1); 
      } 
     } 
    }]); 
</script> 
+1

這將是更好地創建'currencyMask'一個指令 – Satpal

回答