tinymce角度图像选择器语法



我有一个使用angular的ionic应用程序,我想把一个图像选择器放入我在页面上介绍的tinymce编辑器中。

据我所知,在tinymce文档中,它说在html文件中使用角度指令(我也使用了这里的ngModel(:

<h1>TinyMCE 5 Angular Demo</h1>
<editor
[(ngModel)]="dataModel"
[init]="{
height: 500,
menubar: false,
plugins: [
'advlist autolink lists link image charmap print preview anchor',
'searchreplace visualblocks code fullscreen',
'insertdatetime media table paste code help wordcount'
],
toolbar:
'undo redo | formatselect | bold italic backcolor | 
alignleft aligncenter alignright alignjustify | 
bullist numlist outdent indent | removeformat | help'
}"
></editor>

一切正常,但现在我想添加一个图像选择器,但它的文档暗示在ts文件中使用js,比如:

tinymce.init({
selector: 'textarea',  // change this value according to your HTML
file_picker_callback: function(callback, value, meta) {
// Provide file and text for the link dialog
if (meta.filetype == 'file') {
callback('mypage.html', {text: 'My text'});
}
// Provide image and alt text for the image dialog
if (meta.filetype == 'image') {
callback('myimage.jpg', {alt: 'My alt text'});
}
// Provide alternative source and posted for the media dialog
if (meta.filetype == 'media') {
callback('movie.mp4', {source2: 'alt.ogg', poster: 'image.jpg'});
}
}
});

我现在有点卡住了,因为我需要从html中的指令调用file_picker_callback,而且我似乎找不到如何调用。

或者,我想我可以引用js/ts文件中的ngModel,而不是html文件,但我又有点卡住了,因为我不知道该查找什么。

我已经开始阅读棱角分明的文档,以了解正在发生的事情(以及该做什么(,但朝着正确的方向走一点也不会出错。

实际上很简单,只需在html文件中使用this关键字:

file_picker_callback: this.filePickerCallback

然后在typescript文件中创建函数filePickerCallback

最新更新