【发布时间】:2019-03-09 07:42:11
【问题描述】:
如果这对这种情况有意义的话,我想我最终会在 MongoDB 中使用 node/express 后端...
我最终希望能够将内容从内容可编辑 div 保存到后端,以便以后可以从后端重新上传...然后可以将重新上传的数据放在不可编辑的用于显示的 HTML div,或返回到内容可编辑的 div 以进行更多编辑。
有人对此有什么建议吗?也许有一种方法可以保存编辑器 div 中的所有 dom 元素,以一种可以翻译回 HTML 以便呈现的方式?
谢谢,欢迎提出建议
HTML
<div>
<input type="button" (click)="iBold()" value="B">
</div>
<div id='editor' contenteditable>
<h1>A WYSIWYG Editor.</h1>
<p>Try making some changes here. Add your own text.</p>
</div>
角度组件
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-dashboard',
templateUrl: './dashboard.component.html',
styleUrls: ['./dashboard.component.scss']
})
export class DashboardComponent implements OnInit {
constructor() { }
model = '<h1>A WYSIWYG Editor.</h1><p>Try making some changes here. Add your own text.</p>';
editor: any;
ngOnInit() {
this.editor = document.getElementById('editor');
}
iBold() {
document.execCommand('bold', false, null);
}
}
【问题讨论】:
标签: javascript html node.js angular