overleaf/services/web/public/coffee/app/directives/equals.coffee

16 lines
356 B
CoffeeScript
Raw Normal View History

2014-06-20 06:15:25 -04:00
define [
"base"
], (App) ->
App.directive 'equals', () ->
return {
require: "ngModel",
link: (scope, element, attrs, ngModel) ->
scope.$watch attrs.ngModel, () -> validate()
attrs.$observe 'equals', () -> validate()
validate = () ->
equal = (attrs.equals == ngModel.$viewValue)
ngModel.$setValidity('areEqual', equal)
}