European countries use a comma (,) instead of a period (.) When they enter decimal numbers. Therefore, I want to replace the semicolon when users enter input. I know input = number does this, but I need IE support.
Think directive is best to do this? I tried the code below. But he fails.
.directive('replaceComma', function(){ return { restrict: 'A', replace: true, link: function(scope, element, attrs){ scope.$watch(attrs.ngModel, function (v) { var convert = String(v).replace(",","."); attrs.NgModel = convert; }); } } });
The conversion variable is correct. But the value does not change in the input field. So, I think attrs.ngModel = convert, isnβt it?
angularjs
Per
source share