微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决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 举报,一经查实,本站将立刻删除。