【问题标题】:How can to read the content of an ion input element?如何读取离子输入元素的内容?
【发布时间】:2017-12-03 08:01:45
【问题描述】:

我已经测试过了:

this.changedValue = document.getElementById("processID");
this.changedValueString = this.changedValue.value;
console.log("[INFO] Choosen processID: >" + this.changedValueString + "<");

不幸的是,我用 logcat 得到了这个:

[INFO:CONSOLE(56878)] "[INFO] 选择的进程ID:>未定义

【问题讨论】:

  • 我建议您看一下Angular docs,因为您正尝试以 旧 jquery 方式 做事,但是当与 Angular 一起工作。这将帮助您提高应用程序的性能(这对于 Ionic 应用程序来说非常重要)。
  • 好的,我去看看。谢谢。

标签: android typescript ionic-framework ionic3


【解决方案1】:

像这样在输入元素中使用 [(ngModel)],

<input type="text" [(ngModel)]="inputValue" />

在你的 component.ts 中,

export class Page{
inputValue:string;
  constructor(){
    console.log(this.inputValue)
  }
}

【讨论】:

  • 我很高兴它有帮助:)
猜你喜欢
  • 1970-01-01
  • 2017-07-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-11-06
  • 1970-01-01
  • 2021-12-31
  • 1970-01-01
相关资源
最近更新 更多