簡體   English   中英

首先單擊離子頁腳內的按鈕將不會執行(單擊)功能

[英]Click on a button within an ion-footer doesn't execute (click) function at first

我正在與Ionic 2聊天。我使用了鍵盤連接指令。

//View
    <ion-footer [keyboardAttach]="content">
      <ion-toolbar class="text_send">
        <ion-textarea class="textarea" fz-elastic placeholder="Message" [(ngModel)]="message"></ion-textarea>
        <button ion-button small icon-only round color="secondary" (click)="onSend()">
          <ion-icon name="send"></ion-icon>
        </button>
      </ion-toolbar>
    </ion-footer>

// Controller
onSend() {
    console.log('Send new message ', this.message);
    if (this.id === 'new') {
      this.messageService.createChatAndSendFirstMessage(this.cuid, this.recipientUid, this.message)
      .then(newChatId => {
        // Get last messages of the new chat so that it gets displayed in the view
        this.messages$ = this.messageService.getLastMessages(newChatId, this.ccompany, 20);
        // Update chat id in case the user send more than 1 message
        // In this case it should be the regular behavior for non new messages
        this.id = newChatId;
      })
      .catch(error => console.log('ChatPage#onSend - Error while sending new message ', error));

    } else {
      // If a chat already exists with this user
      this.messageService.sendMessage(this.id, this.cuid, this.recipientUid, this.message)
      .catch(error => console.log('ChatPage#onSend - Error while sending new message ', error));
    }

    // Empty the message input
    this.message = '';
  }

當我在iOS上模擬我的代碼並單擊文本區域時,鍵盤顯示:完美。

唯一的問題是,當我單擊發送按鈕時,鍵盤隱藏了,但未執行onSend()函數,因此我不得不再次單擊它。

我如何才能只單擊一次,而這一次單擊將隱藏鍵盤並執行我的onSend()代碼?

我使用鍵盤attach指令在應用程序的各個部分中都做了同樣的事情,沒有任何問題。 我相信這可能是由您使用的(點擊)發射器引起的。

嘗試將其更改為(點擊)

我相信在ios Safari中使用(點擊)存在一些已知問題。 ionic2點擊vs點擊

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM