Angular Sandbox
by Danil Gudz
HTML
<div ng-controller="MyCtrl">
<input type="text" nodot ng-model="name">
</div>
JavaScript
var app = angular.module('myApp',[]);
app.controller('MyCtrl', function($scope) {
$scope.name = "name";
});
app.directive('nodot', function(){
return{
require:'ngModel',
link: function(scope, elem, attrs, ctrl){
ctrl.$parsers.unshift(replace);
function replace(val){
var newVal = val.replace(/,/g, '.');
ctrl.$viewValue = newVal;
ctrl.$render()
return newVal;
}
}
};
});