mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-29 13:03:23 +00:00
16 lines
356 B
CoffeeScript
16 lines
356 B
CoffeeScript
|
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)
|
||
|
}
|