Skip to content

Instantly share code, notes, and snippets.

@lstone
lstone / ui-mask-directive.coffee
Created October 6, 2015 18:27
ui.mask w/ custom placeholder options (focused vs unfocused field)
###*
# @ngdoc directive
# @name ui.mask.directive:uiMask
# @restrict A
# @scope
# @description
# Attaches input mask onto input element. NOTE: This is a custom version the ui-mask plugin that addresses the issue of the placeholder attribute
# overwritten rather than being displayed until the user focuses into the input field. Credit goes to: https://github.com/qwyzyx
#
# @param {String} ui-mask - The keys in maskDefinitions represent the special tokens/characters used in your mask declaration to delimit acceptable ranges of inputs. For example, we use '9' here to accept any numeric values for a phone number: ui-mask="(999) 999-9999". The values associated with each token are regexen. Each regex defines the ranges of values that will be acceptable as inputs in the position of that token.