如何读取离子输入元件的内容?

时间:2017-06-29 14:36:59

标签: android typescript ionic-framework ionic3

我已经测试了这个:

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

不幸的是,我通过logcat获得了这个:

  

[INFO:CONSOLE(56878)]“[INFO]选择processID:&gt; undefined&lt;”

1 个答案:

答案 0 :(得分:1)

在你的输入元素中使用[(ngModel)],如下所示,

>>> fp = open('xyz', 'r')
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'xyz'
>>>
>>> # or with `with`:
... with open('xyz', 'r') as fp:
...     fp.readlnes()
...
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'xyz'
>>>

并在你的component.ts中,

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