Angular 6:根据条件禁用动态复选框 [英] Angular 6: Disable dynamic checkbox based on condition

查看:96
本文介绍了Angular 6:根据条件禁用动态复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有重复复选框列表的动态表单.请参阅 https://stackblitz.com/edit/angular-5jdnb5

I have a dynamic form with repeated checkbox list. Please see https://stackblitz.com/edit/angular-5jdnb5

如果在一个复选框列表中选中了一个复选框选项,则必须在其他列表中禁用同一选项.例如,如果在第一个列表中选中了 Life 选项,则应该在其他列表中禁用Life复选框.

If a checkbox option is checked in one checkbox list, the same option has to be disabled in other lists. For example, if option Life is checked in first list, the Life checkbox should be disabled in other lists.

我如何实现逻辑.请提出建议.

How do i implement the logic. Please suggest.

推荐答案

我创建了一个简化的演示

I have created a simpliifed demo HERE which can be understood by mass audience.

这里的主要概念是维护选项对象和相应的列表ID,用于维护要禁用的列表选项.

The main concept here is to maintain an object of options and the corresponding list id which is used to maintain which list option to disable.

无需在组件之间传递数据,只需对组件模板进行简单的对象操作即可启用/禁用复选框

No need to pass data between components, just simple object manipulation on the component template to enable/disable checkboxes

这篇关于Angular 6:根据条件禁用动态复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆