Its really simple actually, you just need to add that replace function in the $parsers pipeline . $parsers do the needed transformation and validation when any value goes from view to model .
Suppose this is your input tag:
<body ng-app="app">
<input type="text" ng-model="currency">
</body>
Now, in the app.js file :
var app=angular.module('app',[])
app.directive('input',function(){
return {
restrict:'E',
require: 'ngModel',
link: function(scope,elm,attr,ngModelCtrl){
function convert(input){
input = input.replace(/\$/g,'');
input = input.replace(/,/g,'');
return input;
}
ngModelCtrl.$parsers.push(convert);
}
}
})
Here, you are modifying the input directive to replace $ and , with '' (done in the convert function). The convert function is pushed to the $parsers pipeline which will strip off any $ and from any number in the input directive , and store the stripped off number in the model .
Here is a plunker link
You can see the model value "currency" not containing the $ and , sign