Is there any way to know when a model is loaded?
Example:
sap.ui.controller("myapp.MyViewController", { onInit: function() { this.router = sap.ui.core.UIComponent.getRouterFor(this); this.router.attachRoutePatternMatched(this._handleRouteMatched, this); this.model = sap.ui.getCore().byId("app").getModel("mymodel"); }, onAfterRendering: function() { console.log(this.model); } ...
In this case, the model instance is defined, but contains an empty object because the data is not loading.
If I end the console.log method with
setTimeout(function() { console.log(sap.ui.getCore().byId("app").getModel("mymodel")); }, 0);
then the model data loads correctly, but I would like to get something more reliable than using setTimeout.
source share