angular6 使用 UMeditor

参考

angular6 使用 ngx-umeditor
https://github.com/cipchk/ngx-umeditor

具体步骤

1、安装

npm install ngx-umeditor --save

把 UMeditorModule 模块导入到项目中。

import { UMeditorModule } from 'ngx-umeditor';

@NgModule({
	declarations: [AppComponent],
    imports: [
	    BrowserModule,
	    /** 导入 ngx-umeditor 模块 **/
	    UMeditorModule.forRoot(),
    ],
    bootstrap: [AppComponent]
})
export class AppModule { }

2、使用

<nz-tab nzTitle="产品介绍">
	<umeditor [config]="{initialFrameHeight:250}" 
			  [path]="'../../../assets/umeditor/'" 
			  [loadingTip]="'加载中……'"
	          [(ngModel)]="addObj.introduction" 
	          name="full_source" 
	          #full></umeditor>
</nz-tab>
名称类型默认值描述
configObject前端配置项说明,见 http://fex.baidu.com/ueditor/
pathstring./assets/umeditor/umeditor代码根目录路径,以 / 结尾。
loadingTipstring加载中…初始化提示文本。
onReadyFunction编辑器准备就绪后会触发该事件
onDestroyFunction编辑器组件销毁后会触发该事件

3、关于懒加载

懒加载在未到 wdinow.UM 时会启动,如果你在 index.html 已经使用 加载过,懒加载流程将会失效。

加载语言注意点:
懒加载会自动识别并引用,否则,需要自行在 < head> 加入语言版本脚本。

访问umeditor实例对象

  full_source = '';
  @ViewChild('full') full: UMeditorComponent;
  focus: boolean | string;

  addListenerFocus() {
    // 事件监听
    this.full.addListener('focus', () => {
      this.focus = `fire focus in ${new Date().getTime()}`;
    });
  }
  removeListenerFocus() {
    // 事件移除
    this.full.removeListener('focus');
  }

使用 @ViewChild 访问组件

效果如图:
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值