Sha256: 51202b1979191fbc070d38b10849bc183a14c8eaafd5f870e84283c955617a99

Contents?: true

Size: 493 Bytes

Versions: 1

Compression:

Stored size: 493 Bytes

Contents

angular.module('EssayApp.directives').directive "onlyNumbers", [() ->
  restrict: 'A'
  scope: true
  require: "ngModel"
  link: (scope, element, attr, ngModel) ->
    fromUser = (text) ->
      if text?
        transformedInput = text.toString().replace(/[^0-9]/g, "")

        if transformedInput isnt text
          ngModel.$setViewValue transformedInput
          ngModel.$render()

        return transformedInput
      else
        return undefined

    ngModel.$parsers.push(fromUser)
]

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
translation_cms-0.1.5 app/assets/javascripts/app/directives/only_numbers.js.coffee