I've got a WYMeditor instance on my page, and I'd like to control the value of the text inside using AngularJS.
Several methods I've tried and non worked:
Let's assume:
$scope.Details = 'foo';
and it's changing depending on different user actions.
Using ng-model:
<textarea ng-model="Details" class="wymeditor"></textarea>
doesn't work, as when I modify Details, the contents of the actual textarea changes, but it's hidden, and the contents of the inner iFrame that belongs to WYMeditor don't change.
Using WYMeditor's html() function inside my Angular controller:
wym = jQuery.wymeditors(0); wym.html($scope.Details);
This returns an error message referring to WYMeditor's html() function declaration.
Error: this._doc is undefined
I'm Using WYMeditor 0.5, Angular 1.1.5, jQuery 2.0.3 and jQuery-migrate 1.2.1 (for WYMeditor to function with jQuery 2).
I thought of somehow adding ng-model="Details" to the iFrame declaration, but I have no idea on how to do that, and it seems like there's a deeper issue to resolve here that working around like that.
Thanks!
WYMeditor takes some time to initialize. It's best to setup interactions with it in the
postInit
hook.You then setup WYMeditor with something like this:
Please note that the above does not populate the model back. WYMeditor doesn't provide a way to detect changes. The most reliable way is to poll for changes every few seconds. Check out textAngular instead.