Dev*_*555 5 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;
}
}
});
}
}
});
Run Code Online (Sandbox Code Playgroud)
我在上面添加了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>
Run Code Online (Sandbox Code Playgroud)
请注意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>
Run Code Online (Sandbox Code Playgroud)
然后在我的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'
}
});
Run Code Online (Sandbox Code Playgroud)
并在textarea标签:
<textarea ui-tinymce ng-model="tinymce" id="{{fileUploaderID}}_html_tab" name="{{fileUploaderID}}_html_tab" style="width:600px; height:300px"></textarea>
Run Code Online (Sandbox Code Playgroud)
但我收到错误:
ReferenceError: tinymce is not defined
Run Code Online (Sandbox Code Playgroud)
虽然ui js文件添加正常,但我通过查看源代码并单击链接来确认
| 归档时间: |
|
| 查看次数: |
3378 次 |
| 最近记录: |