[英]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.我的前端有下拉菜单,显示数据库中的(名称),我需要从前端获取基于类别 I select 的文件夹。 This is what I have tried in typescript:
这是我在 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 select 的 ID。 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);已解决.. 只需删除“+”即可解决此问题:console,log('Selected Category folder is.'; + this.foldername);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.