I'm using formly to generate forms based on json schema. I need to send a http request for some field options.
JSON :
{
"key": "ReportCode",
"type": "select",
"className": "form-group dropdown-children",
"templateOptions": {
"label": "Report Code",
"options": [],
"httpLookUp": "true",
"controllerPath": "app/controllers/report-management/report-controller",
"controller": "ReportController",
"method": "getReportCodeList",
"valueProp": "Key",
"labelProp": "Key",
"required": true
}
}
And i need to do this :
import(field.templateOptions.controllerPath).then((data: any) => {...
But it's not working.
This is working :
import('app/controllers/report-management/report-controller').then((data: any) => {...
Any ideas ?
Here's the solution :
import(`app/controllers/${field.templateOptions.controllerPath}`)