0
Follow
5
View

Using variable name to access service,model,

dhcbobo 注册会员
2023-01-26 06:43

You can use an object as a dictionary to look up your services, or their function, as you could use a dictionary for any kind of mapping from keys to values:

const serviceMap = {
  "solarpanel": SolarPanelService.getSolarPanel,
  "inverters": InverterService.getInverter
}

let lookupFunction = serviceMap[selected]
lookupFunction().subscribe(
 ...
)

About the Author

Question Info

Publish Time
2023-01-26 06:43
Update Time
2023-01-26 06:43

Related Question

用CentOS senemail发送邮件无效

如何正确设置CKEditor 4的preventDefaultDropOnElement ?

使用Factoextra和FactoMineR在聚类图上添加一些标签

tomcat 启动时一闪而过

Jsonstatdataset rename

错误:1不是函数[factorial, (anon), product, (anon), (anon), (anon), (anon), (anon)]

ckeditor加载后更改默认颜色文本

可替代android中的manage_external_Storage权限

libbluetooth.default.so

将工件(zip文件)从Teamcity发布到Artifactory,还包括版本控制