ค้นหาเว็บไซต์

javascript - วิธีดึงค่าจากฐานข้อมูลตามข้อมูลที่ผู้ใช้ป้อนโดยใช้ Typescript


ฉันจำเป็นต้องดึงค่าจากฐานข้อมูลตามข้อมูลที่ผู้ใช้ป้อน กรุณาดูภาพสแนปชอตของฐานข้อมูลด้านล่าง

ฉันมี dropdown ใน frontend ของฉันที่แสดง (Name) จากฐานข้อมูล ฉันต้องการดึง Folder ตามหมวดหมู่ที่ฉันเลือกจาก frontend นี่คือสิ่งที่ฉันได้ลองใน 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;
        });
    }

ปัจจุบันฉันได้รับ ID ของชื่อที่ฉันเลือกจากเมนูดรอปดาวน์ แต่ฉันไม่สามารถได้รับโฟลเดอร์ได้ ฉันจะแก้ไขปัญหานี้ได้อย่างไร? ช่วยด้วย!!

คำตอบ #1

แก้ไขแล้ว!! เพียงแค่ลบ "+" ก็แก้ไขปัญหานี้ได้ console.log('โฟลเดอร์หมวดหมู่ที่เลือกคือ:', this.foldername);