我在home.html
页面上添加了froala编辑器,但是当我尝试获取div的值时,我无法得到它。我的代码出了什么问题?
home.html 代码:
<ion-content padding>
<form #com="ngForm">
<div [froalaEditor] id="froala-editor-br">Hello, Froala!</div>
<button (click)="onsubmit(com.value)">Click me</button>
</form>
</ion-content>
home.ts 代码:
onsubmit(value: any)
{
this.TAGG = $("#froala-editor-br").froalaEditor('html.get');
console.log("---");
console.log(this.TAGG);
}
点击提交按钮,我在console.log中看到数组。下图附上。
答案 0 :(得分:0)
尝试将div更改为textarea。这是我的代码
home.html
<form [formGroup]="form" (ngSubmit)="onSubmit()">
<ion-label color="primary" stacked>Content</ion-label>
<textarea [froalaEditor] formControlName="formModel" [(froalaModel)]="form.formModel"></textarea>
<button ion-button full type="submit" color="secondary">Save</button>
</form>
Home.ts
constructor(public navCtrl: NavController, private formBuilder:FormBuilder ) {
this.form=this.formBuilder.group({
formModel:['']
});
}
onSubmit(){
console.log(this.form.value);
}