【问题标题】:Ionic Input filed auto create issue离子输入字段自动创建问题
【发布时间】:2018-02-22 18:50:30
【问题描述】:

我将 Ionic 3 用于我的移动应用程序,当我在想要自动创建下一个文件后在输入文件上键入内容时尝试创建,但它不适合我,任何人都知道如何正确地做到这一点

html

<ion-input type="text" placeholder="name" right (keyup.enter)="nextfiled()" ></ion-input>

.ts

nextfiled(value: string): void {
    alert('Submitted value: ' + value);
  }

【问题讨论】:

  • 为什么不使用ionChange
  • @chaos505 我认为 OP 想在按下 Enter 时触发
  • 你的函数似乎期待一个你没有传递的值......控制台中有什么?
  • @SurajRao ah ok 然后(keypress)="eventHandler($event.keyCode)" 就可以了
  • 先生,我不知道,如何为此使用离子变化?任何例子

标签: ionic-framework ionic3 angular5


【解决方案1】:

试试这个:

.html

<ion-item *ngFor="let item of textBox">
    <ion-input type="text" placeholder="name" [(ngModel)]="item.one" (keypress)="addTextBox($event.keyCode)"></ion-input>
</ion-item>

.ts

textBox:any = [{one:''}];

addTextBox(ev){
    console.log('isScroll',ev);
    if (ev == 13) {
        this.textBox.push({one:''});
    }
}

【讨论】:

    【解决方案2】:

    .html

    &lt;ion-input (keypress)="eventHandler($event.keyCode)"&gt;&lt;/ion-input&gt;

    .ts

    eventHandler(keypress) {
        console.log(keypress);
        if(keypress == 13) {
            //run code
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-03-27
      • 1970-01-01
      • 1970-01-01
      • 2016-11-08
      • 2012-06-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多