ng-mdel 輸入自動轉大寫

 .directive('uppercased', function() {
     return {
         require: 'ngModel',      
         link: function(scope, element, attrs, modelCtrl) {
             modelCtrl.$parsers.push(function(input) {
                 return input ? input.toUpperCase() : "";
             });
             element.css("text-transform","uppercase");
         }
     };
 })


input type="text" uppercased ng-model="id"

留言

熱門文章