Created
July 6, 2017 13:49
-
-
Save weeksdev/1721ed0f142b3f53ceb9b400f8100d45 to your computer and use it in GitHub Desktop.
angular currency format example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.directive('currency', function () { | |
return { | |
require: 'ngModel', | |
link: function(elem, $scope, attrs, ngModel){ | |
ngModel.$formatters.push(function(val){ | |
return '$' + val | |
}); | |
ngModel.$parsers.push(function(val){ | |
return val.replace(/^\$/, '') | |
}); | |
} | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="text" ng-model="price" currency> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment