问题描述
这是一个测验应用程序,在这种情况下,我的下一个按钮将重定向到另一个页面,并且默认情况下它已禁用. 如果我选择了所有选项,则应该启用.
This is a quiz app, in this scenario my next button will redirect to another page and it's disabled by default. If I choose all the options it should enable.
注意:
我选择选项并选择正确/错误的功能运行良好,我只是无法弄清楚在选择每个选项时如何启用.
My functionality of selecting options and choosing correct/wrong is working fine, I just can't figure out how to enable when each single option is selected.
有什么帮助或建议吗?工作演示: https://stackblitz.com/edit/angular-ivy-5qtyxy
Any help or suggestions?Working demo: https://stackblitz.com/edit/angular-ivy-5qtyxy
buttonDisabled = true;
<button class="btn-next" [disabled]="buttonDisabled">
Next
</button>
推荐答案
我的看法是将buttonDisabled
定义为吸气剂,然后评估每个问题的状态(如果其状态允许导航到下一页).
My take on this is to define the buttonDisabled
as a getter and then evaluate for each question if it's status allows for the navigation to the next page...
在我的实现中,用户必须选择类型2问题的所有答案,但只能选择类型1问题的一个答案.如果这不是您想要的,请在评论中说明,这对我来说似乎是合乎逻辑的.希望对您有所帮助.
In my implementation the user has to select all of the answers of the type-2-questions, but only one answer on the type-1-questions. If this is not what you want please state so in the comments, it's just what appeared logical to me. I hope it helps you already.
有什么问题吗?只是问问.
Any questions? Just ask.
这篇关于角度-检查是否已选择所有选项以启用按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!