PrimeNG 下拉菜单 - 根据条件禁用某些项目

问题描述

我有一个来自该属性的对象数组,它有两个驱动器号,如 C 和 D。

现在我有一个字符串数组,它在 p-dropdown 中有 A-Z 值我想从下拉列表中禁用 C 和 D 以上。所以用户不能从我的 pr-dropdown 中选择这两个驱动器号。通过使用下面的代码,只有 C 从 p-dropdown 中被禁用:

    for (const item of this.vmWindowsFileSystemDetails) {
      for (const result of driveLetters) {
        if (item.driveLetter.replace(':','') ===  result) {
          this.isletterPresent = true ;
          this.dropDownDriveLetterOptions.push({ label: result + ':',value: result,disabled: this.isletterPresent});
        } else {
          this.isletterPresent = false ;
          this.dropDownDriveLetterOptions.push({ label: result + ':',disabled: this.isletterPresent});
        }
      }
  }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)