【发布时间】:2017-11-03 10:20:48
【问题描述】:
我正在尝试绑定我的输入,即其中包含 html 内容的字符串。 app.component.ts 有“内容”变量
content : string = "<p>This is my editable data.</p><p>Two way binding is not getting applied on it.</p>
public validateProfile(content){
console.log(content);
}
app.component.html 有以下代码
<div contentEditable="true" [innerHTML]="content" [(ngModel)]="content"></div>
<button type="submit" class="btn btn-info" (click)="validateProfile(content)">Validate Profile</button>
我可以编辑标签内的内容。由于我的输入是字符串格式的 html 数据,我无法将其绑定到输入标签。 有人可以建议如何在 div 或 span 上应用 contenteditable= true 的 2 路绑定。
【问题讨论】:
-
ng-model 不适用于 contenteditable。
-
ngModel 使用文本框
INPUT, TEXTAREA
标签: angular