Set angular -ui-tinymce editor contents after navigation

I am using angular -ui-tinymce (latest version 0.0.4, https://github.com/angular-ui/ui-tinymce/blob/master/src/tinymce.js ).

I ran into a problem that I cannot solve.

When loading the first page, the contents are loaded into the editor via ng-model. Then I go into another state, and then go back to the editor. The value still exists in the area (I checked it), but the content does not appear in the editor for some reason, I cannot figure it out.

This is a text field with a directive as an attribute:

<textarea rows="10" class="form-control" id="desc" ui-tinymce ng-model="valueFromScope"></textarea> 

This happened after updating AngularJS from 1.5 to 1.2.1. I thought this had something to do with ngSanitize, but I'm not sure.

btw angular -sanitize and ngSanitize are included in the application.

Any tips?

Update
It looks like ngModel. $ Render does nothing.

  ngModel.$render = function() { console.log(ngModel); tinyInstance = tinymce.get(attrs.id); if (tinyInstance) { tinyInstance.setContent(ngModel.$viewValue || ''); updateView(); } }; 

Nothing is printed, not even undefined, which means ngModel. $ render does not even start. Any reasons for this?

Update
I do not think the model. $ Render is connected, from what I understand. $ Render is only executed when programmatically changing, like, actually, editing text and what works.

I still can't figure it out, sometimes the value is displayed, and sometimes not.

+7
javascript angularjs tinymce angular-ui
source share
2 answers

The problem is solved! - presently..

Thanks to @alonisser, I found a solution.

From what I understand, the problem arises because something has changed in prioritizing angularjs directives.

read the following: http://iwang.imtqy.com/html/angular/angularjs/2013/11/04/ngmodel-render-cannot-be-overriden-in-angular-rc3.html

a simple fix is ​​to add a priority definition to the directive

 return { priority: 10, require: 'ngModel', 
+13
source share

Setting priority does not really solve the problem.

The only thing that worked for me was to add the following code before ngModel.$render = function()

  var stopWatch = scope.$watch(attrs.ngModel, function(newValue){ if (!tinyInstance){ tinyInstance = tinymce.get(attrs.id); } if (tinyInstance) { tinyInstance.setContent(newValue); stopWatch(); } }); 
0
source share

All Articles