ngModel。$渲染不叫时模式的变革 [英] ngModel.$render is not called when model change

查看:89
本文介绍了ngModel。$渲染不叫时模式的变革的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用微小的-MCE与棱角分明,但我有一些麻烦与$渲染功能的指令。
当我更新的模式,呈现$函数不叫。

I'm trying to use tiny-mce with angular, but i have some trouble with the $render function in the directive. When i update the model, the $render function is not call.

下面一个plunkr来说明: http://plnkr.co/edit/Ih1nDq p = preVIEW

Here a plunkr to illustrate: http://plnkr.co/edit/Ih1nDq?p=preview

我不知道,但我认为它可能与角1.2,因为具有角1.1.5,
有用 :
http://plnkr.co/edit/LXAtHd?p=$p$pview

I'm not sure, but i think it could be related to angular 1.2, because with angular 1.1.5, it works : http://plnkr.co/edit/LXAtHd?p=preview

这是角1.2个bug,或者我错过了什么新的具有角1.2?

Is this a bug of angular 1.2, or did i miss something new with angular 1.2?

推荐答案

这个答案显示,code你在你的指令需要做渲染断火时必要的:

This answer shows code you need in your directive to make render fire off when necessary:

<一个href=\"http://stackoverflow.com/questions/20005699/tinymce-textarea-two-way-bound-with-angularjs\">TinyMCE &LT; TextArea&GT;两路与AngularJS

        // When your model changes from the outside, use ngModel.$render to update the value in the textarea
        ngModel.$render = function () {
            textarea.val(ngModel.$viewValue);
        };

也比较从角-UI-TinyMCE的这个渲染功能( https://github.com /角度的UI / UI-TinyMCE的

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

Plnkr: http://plnkr.co/edit/04AFkp?p=preVIEW

但是取决于你的DOM加载的时间,您可能需要向上设置你的指令的优先级。 : - )

However depending on the timing of the loading of your DOM you may need to set the priority on your directive upwards. :-)

这篇关于ngModel。$渲染不叫时模式的变革的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆