kennyki / angular-pagedown

A pagedown editor (used in StackOverflow) for AngularJS
MIT License
23 stars 13 forks source link

textarea isn't part of angular form controllers #8

Closed b-dean closed 9 years ago

b-dean commented 9 years ago

The textarea element that is created doesn't show up on the FormController of a form it's part of.

This means you can't tell if the textarea is dirty. I've created a fork of the angular-pagedown example plunker that has some more form elements that shows what's going on:

http://plnkr.co/edit/0FpsAnV0dpwQQnXIAkhy

I'm guessing that it is somehow because of the textarea for the pagedown editor being in a different ngScope.

MichaelBuen commented 9 years ago

Used ngModel.$setDirty to raise the dirtiness to the FormController. ngModel.$setDirty appears on Angular 1.3.4.

Here's a working demo: http://plnkr.co/edit/Eh00BqldBS1VorerN9qH?p=preview

kennyki commented 9 years ago

bower update to 0.4.4 ;-)

MichaelBuen commented 9 years ago

@b-dean looks like conforming to ng-model attribute would make the directive appear on FormController, on the fork I used ng-model attribute instead of custom attribute content.

Here's the demo: http://plnkr.co/edit/0vOkOmm9z4yCZY3ATuFp?p=preview

The latest commit below also fixed the delayed model value when user's ng-change is called.

https://github.com/MichaelBuen/angular-pagedown/commit/2a77bda5db1b4f85528ee9ebad0e606e382c638e