Skip to content

Instantly share code, notes, and snippets.

@davidalves1
Created September 26, 2016 19:21
Show Gist options
  • Save davidalves1/9d95bb2278ce18fcfa0d4f315944a123 to your computer and use it in GitHub Desktop.
Save davidalves1/9d95bb2278ce18fcfa0d4f315944a123 to your computer and use it in GitHub Desktop.
Diretiva para formatar nomes
(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