【发布时间】:2019-02-07 20:12:45
【问题描述】:
我对如何处理这件事有点困惑。我的应用程序中有一个“提要”,提要中的每个帖子都有一个评论框。下面是一些示例代码:
<ion-card class="feed" *ngFor="let post of feed">
<ion-item no-lines class="comment-input">
<ion-input type="text" placeholder="Write comment ..."></ion-input>
<button item-right ion-button (click)="feedPostComment(post)">Comment</button>
</ion-item>
</ion-card>
现在我正在努力找出使用feedPostComment() 从其上方的输入字段中提取文本的最佳方法。我知道我可以使用ngModel,并且在许多情况下,我在页面上没有以这种方式重复的表单和输入系统,但我无法理解在这种情况下我将如何做到这一点。
我在想我可以将post.id 设置为ion-input 上的id 或name 字段,并直接通过DOM 定位输入字段,但我意识到这不是一个好习惯。
另一件事是,Feed 本身会定期更新新帖子。提前致以最诚挚的感谢。
【问题讨论】:
标签: angular typescript ionic-framework input