Ionic

时间:2018-03-13 10:18:12

标签: angular ionic-framework ionic2 ionic3

我正在尝试从 home.html 中获取富文本区域的值,但是我收到了错误。

Home.html 代码如下:

<ion-content>
    <rich-text [formControlItem]="item" placeholderText="A sample of placeholder text"></rich-text>

    <div padding [innerHTML]="item.value" ></div>
    <button ion-button (click)="abc(item)"></button>
</ion-content>

Home.ts 代码如下:

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { FormControl, FormBuilder, FormGroup } from "@angular/forms";

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  item: FormControl;

  constructor(public navCtrl: NavController, private formBuilder: FormBuilder) {

  }

  ionViewWillLoad() {
    this.item = this.formBuilder.control('');
  }

  abc(item)
  {
    console.log("HELLO");
    console.log(item,"ITEM");
  }
}

单击按钮获取值时出现错误:

enter image description here

如何在变量中获取富文本区域的值?

2 个答案:

答案 0 :(得分:0)

注意const expressInstance = express(); express.use(timeout('4')); express.use((err, res, req, next) => req.jsonp(err)); // DON'T USE FOR PRODUCTION const app = NestFactory.create(AppModule, express); 方法的括号,它应该是这样的:

abc(item)

答案 1 :(得分:0)

你必须像这样使用它

<ion-content>
    <rich-text [(ngModel)]="item" name="item" placeholderText="A sample of placeholder text"></rich-text>
    <div padding [innerHTML]="item.value" ></div>
    <button ion-button (click)="abc(item)"></button>    
</ion-content>

ngModel用于双向数据绑定以获取更多信息,请参阅此link