CKEditor的不显示时AngularJS掉其观点, [英] CKEditor not showing when AngularJS swap its view

查看:122
本文介绍了CKEditor的不显示时AngularJS掉其观点,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我AngularJS指令是:

My AngularJS Directive is:

.directive('ckEditor', function() {
  return {
    require: '?ngModel',
    link: function(scope, elm, attr, ngModel) {
      var ck = CKEDITOR.replace(elm[0]);

      if (!ngModel) return;
      ck.on('pasteState', function() {
        scope.$apply(function() {
          ngModel.$setViewValue(ck.getData());
        });
      });

      ngModel.$render = function(value) {
        ck.setData(ngModel.$viewValue);
      };
    }
  };

比方说,我的看法是类似以下内容:

Let's say My View is like following:

<textarea ck-editor  name="menu_content" style="width:600px; height:300px;" id="menu_content" ng-model="models.menu_content" ub-search-settings=""></textarea>

在该视图称为CKEditor的显示,而不是文本区域。没关系。
现在,我的问题是CKEditor的不显示时的观点是呼吁下一次不刷新整个页面。

When the view is called CKEditor shows instead of TextArea. It's ok. Now, my problem is CKEditor not showing when view is call for next time not reloading the whole page.

推荐答案

添加到您的指令:

          ck.on('instanceReady', function() {
            ck.setData(ngModel.$viewValue);
          });

这篇关于CKEditor的不显示时AngularJS掉其观点,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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