Angular 如何访问角度组件内部的可编辑div
我正在寻找从html模板访问div的方法 我有html格式的Angular 如何访问角度组件内部的可编辑div,angular,contenteditable,Angular,Contenteditable,我正在寻找从html模板访问div的方法 我有html格式的 <div #postStatus contenteditable="true" class="form-control" placeholder="" (keyup)="postForm.value.content=postStatus.innerText"></div> 但这给了我一个错误: ERROR ReferenceError: postStatus is not defined 是否有合适的方法从
<div #postStatus contenteditable="true" class="form-control" placeholder="" (keyup)="postForm.value.content=postStatus.innerText"></div>
但这给了我一个错误:
ERROR ReferenceError: postStatus is not defined
是否有合适的方法从我的component.ts文件中访问该值?
而且,为了让用户看到和实际提交的文本不同,必须是@[猫鼬对象id],但用户需要看到他们在开始书写@+大写字母时从列表中选择的人的姓名,但如果他们没有选择,但写姓名和姓氏时,即使使用@也必须显示他们所写内容的确切文本,类似的内容应该可以:
import { Component, ElementRef, ViewChild} from '@angular/core';
class SomeCmp {
@ViewChild("postStatus") postStatus : ElementRef;
reset(){
this.postStatus.nativeElement.innerText = "";
}
}
你不需要这样做吗。postStatus。nativeElement。innerText?谢谢。成功了。现在唯一的问题是,如何才能在innerText中显示@[mongoose obj.id],但对于字段中的用户,只显示一些其他相关数据,但如果用户删除了这些数据,那么也删除这个@[mongoose obj.id],您不能这样做。如果更改了innerText,则该字段将显示innerTextvalue@BougarfaouiElhoucine那么FB用户如何标记?
import { Component, ElementRef, ViewChild} from '@angular/core';
class SomeCmp {
@ViewChild("postStatus") postStatus : ElementRef;
reset(){
this.postStatus.nativeElement.innerText = "";
}
}