2017-05-03 167 views
2

当输入/文本字段变得聚焦(?)时,离子键盘打开。离子2 - 当点击发送按钮时保持键盘打开

但是当我点击发送按钮时,键盘消失。

即使我调用键盘插件的keyboard.show()方法,它会先消失,然后再次出现。

有没有解决方案?

<textarea id="chat-text-area></textarea> 

sendMessage() { 
    if(window.cordova){ 
     this.keyboard.show() 
    } 
    if(this.form.valid){ 
     this.service.post(this.form.value).subscribe(res=>{ 
      document.getElementById('chat-text-area').focus() 
     }) 
    } 
} 

回答

0

你可以在隐藏事件中注入逻辑吗?

window.addEventListener('native.keyboardhide', keyboardHideHandler); 

function keyboardHideHandler(e){ 
    if (something) // put your condition here 
     e.preventDefault(); 
} 
0

添加到您的发送按钮:

(mousedown)="$event.preventDefault(); sendMessage($event)" 

我希望帮助:)

+0

大和简单的解决方案,感谢,到目前为止! – Unkn0wn0x

相关问题