How execute code every time that I view a page

There is a solution for you. There is a event called routeMatched when navigation is triggered every time. You can attach the event in the detail page.

 onInit : function () {
    this._oRouter = sap.ui.core.UIComponent.getRouterFor(this);
    this._oRouter.attachRouteMatched(this.handleRouteMatched, this);
},

handleRouteMatched : function (evt) {
    //Check whether is the detail page is matched.
    if (evt.getParameter("name") !== "detail") {
        return;
    //You code here to run every time when your detail page is called.
}

Leave a Comment