Created
September 26, 2016 19:21
-
-
Save davidalves1/9d95bb2278ce18fcfa0d4f315944a123 to your computer and use it in GitHub Desktop.
Diretiva para formatar nomes
This file contains 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
(function () { | |
'use strict'; | |
angular | |
.module('ngNameFormat', []) | |
.directive('nameFormat', nameFormat); | |
function nameFormat() { | |
return { | |
require: 'ngModel', | |
link: function(scope, el, attrs, ngModel) { | |
el.bind('input', function () { | |
scope.$apply(function () { | |
ngModel.$setViewValue(el.val().replace(/(?:^|\s)\w/g, function(match) { | |
return match.toUpperCase(); | |
}) | |
); | |
ngModel.$render(); | |
}); | |
}); | |
} | |
} | |
} | |
function formatter(char) { | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment