html代码:
<angular-editor [placeholder]="'Enter task...'" formControlName="task_note" [config]="editorConfig">
</angular-editor>
<div class="icon" style="cursor: pointer" (click)="editTaskbtn(task)" (click)="openTask(cont)">
<img src="assets/Deals Icons/Edit icon.svg" style="height: 24px" alt="" srcset="" />
</div>
.ts 文件:
editorConfig: AngularEditorConfig = { 可编辑:真实, 拼写检查:正确, 高度:'自动', 最小高度:'0', 最大高度:'自动', 宽度:'自动', 最小宽度:'0', 翻译:“是”, 启用工具栏:true, 显示工具栏:真, 默认段落分隔符:'', 默认字体名称:'', 默认字体大小:'', 字体:[ { 类:'arial',名称:'Arial' }, { class: 'times-new-roman', name: 'Times New Roman' }, { 类:'calibri',名称:'Calibri' }, { class: 'comic-sans-ms', name: 'Comic Sans MS' }, ], 自定义类:[ { 名称:'报价', 类:'报价', }, { 名称:'红色文本', 类:'红色文本', }, { name: '标题文本', 类:'标题文本', 标签: 'h1', }, ], uploadUrl: 'v1/图片', uploadWithCredentials:假, 消毒:假, 工具栏位置:'顶部', 工具栏隐藏按钮:[ [ '撤消', '重做', '删除线', '下标', '上标', '缩进', '突出', '标题', ], [ '文字颜色', '背景颜色', '自定义类', '关联', '取消链接', '插入图片', '插入视频', '插入水平规则', '删除格式', '切换编辑器模式', ], ], };
表单控制:
private _initTasksForm() {
this.tasksFormGroup = this.formBuilder.group({
contact_owner: ['', Validators.required],
priority: ['', Validators.required],
task_type: ['', Validators.required],
task_reminder: ['', Validators.required],
custom_reminder: [''],
date_time: ['', Validators.required],
task_note: ['', Validators.required],
isClosed: [''],
});
}
要绑定的数据 { "_id": "670cb62498a51532489dd41f", "customer_id": "OGYCON1728883573551", “创建者”:“OGYU1728878104362”, “类型”:“任务”, “优先级”:“无”, “参数”:{ "contact_owner_unqid": "OGYU1728878104362", “优先级”:“无”, "task_type": "待办事项", "task_reminder": "无提醒", “自定义提醒”:“”, "date_time": "2024-10-18T06:11:32.000Z", "task_note": "
when submitting the data using the editor data is saved as HTML, but after that when I open the editor to view the data to get edit, in angular kolkov editor data is displayed as
<ul><li>ccccc</li><li>aaaa</li><li>bbbb</li></ul>
private _setTasksData(task) {
....
this.tasksForm?.['task_note'].setValue(
this.transform(task.param.task_note)
);
}
transform(value: any): any {
return value.split('<').join('<').split('>').join('>');
}
上面的代码解决了我的问题,代码现在可以运行。