繁体   English   中英

如何使用 Typescript 根据用户输入从数据库中获取值

[英]How to get the value from DB based on the user input using Typescript

我需要根据用户输入从数据库中获取值。 请在下面找到数据库的快照。

在此处输入图像描述

我的前端有下拉菜单,显示数据库中的(名称),我需要从前端获取基于类别 I select 的文件夹。 这是我在 typescript 中尝试过的:

    loadResourceCategory() {
      this.categories = new Array<ResourceCategory>();
      this.isLoading = true;

      return this.resourceService.getResources()
        .then((categories: Array<ResourceCategory>) => {
          this.categories = categories;
          this.categories.forEach((category: any) => {
            category.details = `${category.Name}`;
            this.selectedCategory = category.Id;

            if (category.Id === this.selectedCategory) {
              this.foldername = category.Folder;
              console.log('Selected Category folder is :', + this.foldername);
            }
          });
        })
        .catch(() => {
          this.modalService.error('Resources cannot be loaded now, Please retry later');
        })
        .finally(() => {
          this.isLoading = false;
        });
    }

目前,我从下拉列表中获得名称 i select 的 ID。 我无法获取文件夹。 我怎样才能解决这个问题? 请帮忙!!

已解决.. 只需删除“+”即可解决此问题:console,log('Selected Category folder is.'; + this.foldername);

暂无
暂无

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

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