当我单击回复按钮时,我将焦点重定向到已经用于发布评论的文本字段,现在我希望该文本框也发布回复 -调用focusInput(input)时,它将聚焦到页脚中的文本区域-
<button (click)="focusInput(input)" style="background-color:transparent">
<p style="color:dodgerblue;font-size: 16px">Reply</p>
</span></button>
<ion-footer>
<ion-list style="text-align: center">
<ion-row>
<ion-col>
<ion-item text-wrap>
<ion-textarea #input type="text" id="myInput1" [(ngModel)]="body" placeholder="Write a Comment" spellcheck="true" autoComplete="true" autocorrect="true" autosize></ion-textarea>
</ion-item>
</ion-col>
<button (click)="postComments(commentsList.id,i)" icon-only item-right class="send-chat-button" style="background-color: transparent">
<ion-icon name="send" style="color:orange"></ion-icon>
</button>
</ion-row>
</ion-list>
//.ts file
focusInput(input) {
input.setFocus();
}
postComments() {
//console.log(this.userDetails)
let commentPost = {
"post_id": this.commentsList.id,
"body": this.body,
"user" :{ "name":this.userDetails.name,"photo": {"file":this.userDetails.photo.file}},
}
this.service.postComment(commentPost)
.subscribe(data => {
this.returndata = data;
console.log(this.returndata)
//this.commentsList.comment.push(this.returndata)
})
this.commentsList.comment.push(commentPost);
this.body = "";
}