stevermeister / ngWig

simple WYSIWYG editor for AgularJS, for Angular2+ please use - https://github.com/stevermeister/ngx-wig
http://stevermeister.github.io/ngWig/
MIT License
113 stars 62 forks source link

required working only if placeholder present #149

Open rolintoucour opened 8 years ago

rolintoucour commented 8 years ago

I added a ng-required attribute to ng-wig and noticed that, on the first focus on the ng-wig, the input was validated (even if empty).

The problem is that, on $onInit, a '

' is inserted in the model, so the required validation cannot work.

A temporary workaround is to use a placeholder (

isn't inserted this way).

bampakoa commented 8 years ago

The validation does not work because a <p> element is inserted by default if there is no value of the model. I think this is done by design thus you have to control the required behavior in a custom way

For example, if you want to disable a submit button when the editor has no content yet:

<button role="submit" ng-disabled="editor.model === '<p></p>'"></button>