Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
$element.on('input', function formatInput () {
var input = $element.val()
if (!input) return
var element = $element[0]
var formatted = card.format(card.parse(input))
var selectionEnd = element.selectionEnd
ngModel.$setViewValue(formatted)
ngModel.$render()
if (selectionEnd === input.length && input.length < formatted.length) {
selectionEnd = formatted.length
}
setCursorPostion(element, selectionEnd)
})
}