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');
    };
})
                Give this a try see what comes up :
 text.toString().replace(/.(?=.{4})/g, 'X')
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With