我正在尝试将变量 commentEdit 从viewbook.component.ts
传递给tinymce.component.ts
,但它收到错误的值。
问题是tinymce.component.ts
中的“评论”总是收到一个空字符串''。
当我点击 span 时,commentEdit会获得一个新值,但它不会更新其他组件上的值。
我该怎么做?
viewbook.component.ts
...
export class ViewBookComponent implements OnInit {
public commentEdit= '';
public comment='';
...
keyupHandlerFunction(bookComment) {
this.comment = bookComment;
}
openModalEdit(comment) {
this.commentEdit = comment;
}
...
}
viewbook.component.html
...
<span (click)="openModalEdit(comment.comment)" data-toggle="modal"...></span>
...
<tinymce
[elementId]="'edit-comment-book'"
[plugins]="['link', 'paste']"
[comment]='commentEdit'
(onEditorKeyup)="keyupHandlerFunction($event)"
>
</tinymce>
...
tinymce.component.ts
export class TinymceComponent implements AfterViewInit, OnDestroy {
@Input() comment: String;
...
谢谢!
编辑:我已使用ngOnChanges()Tinymce Angular 2 integration : how to set the content of the editor?
解决了这个问题答案 0 :(得分:0)
如果您尝试访问html模板上的值,请尝试使用getter和setter。如果需要,可以提供更多信息。