Reputation: 299
I am trying to mask all the chars except the last four using a filter in angularjs. I am getting the following error.
HTML :
<table>
...
<tr ng-repeat="emp in FiltredCorpEmployees | orderBy:propertyName:reverse" ng-model="emp.evaluationStatusId">
<td class="col-md-2 text-center">{{emp.hashSSN | MaskText}}</td>
</tr>
..
</table>
JS :
DashBoardModule.filter('MaskText', function () {
//debugger;
return function (text) {
if (!text) {
return text;
}
return text.replace(/.(?=.{4})/g, 'X');
};
})
Upvotes: 9
Views: 12147
Reputation: 825
convert to string
<td class="col-md-2 text-center">{{emp.hashSSN.toString() | MaskText}}</td>
Upvotes: 0
Reputation: 45986
Give this a try see what comes up :
text.toString().replace(/.(?=.{4})/g, 'X')
Upvotes: 14