5

我有问题我无法弄清楚,但我确实有一个提示。在集成 TinyMCE 之前,主导航运行良好,例如链接设置、分析、设置;如果您单击它们,它现在不起作用。

这是我的js文件:

var app_htmleditor_module = angular.module('app_htmleditor', ['components']).
    config(['$routeProvider', function($routeProvider) {
        $routeProvider.
            when('/', {templateUrl: getBaseURL()+'public/tpl/app/htmleditor.htm',   controller: HtmlEditorCtrl, reloadOnSearch:false }).
            otherwise( {redirectTo: '/'});
    }
]);
    
angular.module('components', []).directive('imageUpload', function () {
    return {
        restrict: 'E',
        scope: {
              uploaderid:'@uploaderid'
            },
        templateUrl: '/public/tpl/imageupload.htm'
    }
});
        
app_htmleditor_module.directive('uiTinymce', function() {
     return {
         
         require: 'ngModel',
         link: function(scope, element, attrs, ngModel) {
             
             element.tinymce({
                 // Location of TinyMCE script
                 script_url: 'http://resources.holycrap.ws/jscripts/tiny_mce/tiny_mce.js',

                 // General options
                 theme: "simple",

                 // Change from local directive scope -> "parent" scope
                 // Update Textarea and Trigger change event
                 // you can also use handle_event_callback which fires more often
                 onchange_callback: function(e) {

                     if (this.isDirty()) {
                         this.save();

                         // tinymce inserts the value back to the textarea element, so we get the val from element (work's only for textareas)
                         //ngModel.$setViewValue(e.getBody().innerHTML);
                         ngModel.$setViewValue(element.val());
                         scope.$apply();
                         
                         return true;
                     }
                 }
             });

         }
     }
});

我将上面的tinymce指令添加到textarea中,ui:tinymce如下所示:

<textarea ui:tinymce ng-model="data.html_tab" id="{{fileUploaderID}}_html_tab" name="{{fileUploaderID}}_html_tab" style="width:600px; height:300px"></textarea>

注意ui:tinymce上面。如果我删除它,导航会再次正常工作。那么如何使我的导航ui:tinymce在 textarea 中添加?

演示网址:

http://dev-socialapps.rkm-group.com/app/htmleditor/index#/

任何帮助将不胜感激。谢谢

更新:

按照建议,我首先将 ui js 文件添加到我的模板文件中:

<script src="https://raw.github.com/angular-ui/angular-ui/master/build/angular-ui.js"></script>

然后在我的 js 文件中,我添加了:

var app_htmleditor_module = angular.module('app_htmleditor', ['components', 'ui']).
    config(['$routeProvider', function($routeProvider) {
        $routeProvider.
            when('/', {
                templateUrl: getBaseURL()+'public/tpl/app/htmleditor.htm',
                controller: HtmlEditorCtrl,
                reloadOnSearch:false
            }).
            otherwise( {redirectTo: '/'});
    }
]);

app_htmleditor_module.value('ui.config', {
   tinymce: {
      theme: 'simple'
   }
});

在 textarea 标签中:

<textarea ui-tinymce ng-model="tinymce" id="{{fileUploaderID}}_html_tab" name="{{fileUploaderID}}_html_tab" style="width:600px; height:300px"></textarea>

但我收到错误:

ReferenceError: tinymce is not defined

虽然 ui js 文件添加得很好,但我通过查看源代码并单击链接确认

4

1 回答 1

1

Have you tried the latest version of the tinymce directive in the angular-ui library?

Demo

JS file

于 2012-07-09T09:29:12.310 回答