2017-06-13 6 views
0

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()コードを実行できますか?

答えて

1

私のアプリケーションのさまざまな部分で同じことを問題なくキーボードアタッチディレクティブで行っています。あなたが使用している(クリック)エミッタによって引き起こされている可能性があります。

は(タップ)に変更する

を試してみてください私は、iOSのSafariで(クリック)を使用していくつかの既知の問題があると考えています。 ionic2 tap vs click

関連する問題