在tinymce指令之后,AngularJS Navigation不起作用

时间:2012-07-09 07:29:49

标签: javascript tinymce angularjs

我有问题我无法弄清楚,但我有一个提示。在集成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;
                     }
                 }
             });

         }
     }
});

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

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

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

DEMO网址:

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文件添加正常但我通过查看源代码并点击链接

确认

1 个答案:

答案 0 :(得分:1)

您是否在angular-ui库中尝试过最新版本的tinymce指令?

Demo

JS file