overleaf/services/web/public/coffee/directives/equals.coffee
2014-07-31 11:16:13 +01:00

15 lines
No EOL
324 B
CoffeeScript

define [
"base"
], (App) ->
App.directive "equals", [->
return {
require: "ngModel"
link: (scope, elem, attrs, ctrl) ->
firstField = "#" + attrs.equals
elem.add(firstField).on "keyup", ->
scope.$apply ->
equal = elem.val() == $(firstField).val()
ctrl.$setValidity "areEqual", equal
}
]