简体   繁体   中英

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

I need to get the value from Database based on the user input. Please find below snapshot of the DB.

在此处输入图像描述

I have dropdown in my frontend which display the (Name) from the database, I need to get the Folder based on the category I select from the frontend. This is what I have tried in 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;
        });
    }

Currently I get the ID of the Name i select from the dropdown. I am unable to get the Folder. How can I fix this? Please help!!

Solved.. Just removing "+" resolved this issue: console,log('Selected Category folder is.'; + this.foldername);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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