简体   繁体   English

如何使用angular8根据上一个和下一个按钮单击使表单中的数据发生变化

[英]How to make the data in form to change based on previous and next button click using angular8

i have used reactive forms, so based on selection of item in the right hand side, left side form is getting replaced with the particular row values.我使用了反应形式,因此根据右侧的项目选择,左侧的形式将被特定的行值替换。 Now instead of changing the row values by manual click, if i click on previous and next it must take up the previous value from list and vice versa, if the selected value is the first in table then previous must be disabled and next must be enabled, if selected value is last then next button to be disabled.现在不是通过手动单击更改行值,如果我单击上一个和下一个,它必须从列表中获取前一个值,反之亦然,如果所选值是表中的第一个,则必须禁用上一个,必须启用下一个, 如果选择的值是最后一个,则下一个按钮将被禁用。 I searched so many things but nothing helped me to solve my issues.我搜索了很多东西,但没有任何帮助我解决我的问题。

DEMO: DEMO演示: 演示

TS: TS:

previousValue() {
    --this.userDetails.id
  }

  nextValue() {
    ++this.userDetails.id
  }

If I understand your case correctly - it's your solution: https://stackblitz.com/edit/github-ck3u8u-3lwowg?file=src%2Fapp%2Fapp.component.ts如果我正确理解您的情况 - 这是您的解决方案: https : //stackblitz.com/edit/github-ck3u8u-3lwowg?file=src%2Fapp%2Fapp.component.ts

then based on userIndex value and the length of the list you can disable buttons.然后根据 userIndex 值和列表的长度,您可以禁用按钮。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM