TerryMooreII / angular-wysiwyg

An AngularJS WYSIWYG directive that multiple instances and two-way data-binding.
MIT License
121 stars 75 forks source link

Form validation #43

Open maroun-baydoun opened 9 years ago

maroun-baydoun commented 9 years ago

Validation errors of the angular-wysiwyg are not showing as part of the errors of the parent form. Is that the expected behavior? How to get the validation errors from angular-wysiwyg ?

samuel-gay commented 9 years ago

It took a little while, but I've found that if you surround the wysiwyg tag with an ng-form tag you can reference the forms $invalid,

(this assumes that you have added your own validation to ngModelCtrl.$validators)

<div ng-form="exampleForm">
<wysiwyg textarea-name="text" ng-model="data"></wysiwyg>
{{exampleForm.text.$invalid}} this didn't work for me
{{exampleForm.$invalid}} this did work however
</div>