Reputation: 3
Would like to explain it with example. Suppose we have a controller and we try to create a model using - var oModel = new sap.ui.model.json.JSONModel({});
But we have no where loaded sap/ui/model/json/JSONModel before writing this code.
Will it work? If yes, then why does it throw error in some other scenarios.
May be I am little confused regarding library and module loading in ui5 application, so could anyone help with it?
Upvotes: 0
Views: 429
Reputation: 1026
Referencing UI5 modules with their fully qualified module name (e.g. new sap.ui.model.json.JSONModel()
) is not recommended at all!
Is there any reason why you don't add "sap/ui/model/json/JSONModel"
to the controller's dependency?
If you really need to access a module at runtime, at least encapsulate it in sap.ui.require
//...
sap.ui.require([
"sap/ui/model/json/JSONModel"
], function(JSONModel) {
const oModel = new JSONModel({});
// ...
});
sap.ui.require
Upvotes: 1