Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ctrl.$setViewValue(_formatContaBanco(scope.model));
- ngModel.$formatters.push(function(value) {
- return value.toUpperCase();
- });
- ngModel.$parsers.push(function(value) {
- return value.toLowerCase();
- angular.module('app').directive('contaCorrenteMask', function () {
- return {
- restrict: 'A',
- require: "ngModel",
- link: function (scope, element, attrs, ctrl) {
- var _formatContaBanco = function (data) {
- if (!data)
- return data;
- if (data.length == 1)
- return data;
- data = data.replace(/[^0-9]+/g, "");
- var digito = data.slice(-1);
- var conta = data.slice(0, -1);
- return conta + '-' + digito;
- };
- // Send out changes from inside:
- ctrl.$formatters.push(function (modelValue) {
- return _formatContaBanco(modelValue);
- });
- }
- };
- })
Add Comment
Please, Sign In to add comment