cancel
Showing results for 
Search instead for 
Did you mean: 

how to set relative path in sapui5?

honam_yu
Explorer
0 Kudos
4,637

hi experts

I make sapui5 project above.

I access products.json file from App.controller.js

I use relative path --> ../json/products.json. but I cannot load json file.

And I use ./json/products.json.

why different general relative path?

thanks

View Entire Topic
prashil
Product and Topic Expert
Product and Topic Expert

Hi Honam,

The best way to have the json file loaded is already have it resolved with respect to your project module path.

var sProductsJsonPath = jQuery.sap.getModulePath("com.prashil.test", "/json/products.json");

var oProductModel = new sap.ui.model.json.JSONModel(sProductsJsonPath);

This way you no matter if your UI5 app is launched from Fiori Launchpad or standalone or SCP, it will always resolve the proper reference.

Thanks

Prashil

honam_yu
Explorer

Hi Prashil

thank you your replay

I solve my problem.

and I looked for the latest API, jQuery.sap is deprecated as of version 1.58.

Is there any other way not deprecated?

thanks