Is there some way how to know when 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 it contains empty object, because no data is loaded.
If I wrap the console.log method with:
setTimeout(function() {
console.log(sap.ui.getCore().byId("app").getModel("mymodel"));
}, 0);
then model data gets loaded correctly, but I would like something more reliable than using setTimeout.